size some stringbuffer to prevent re-alloc
I started with 32 and kept doubling the size until the site did not need re-alloc, but clamped it at 512. Change-Id: I55fe36b31cd3d40f86e5729337a927cf920f2af6 Reviewed-on: https://gerrit.libreoffice.org/81960 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
committed by
Noel Grandin
parent
ab285c743a
commit
48101a1a0d
@@ -1641,7 +1641,7 @@ EBulletInfo Outliner::GetBulletInfo( sal_Int32 nPara )
|
||||
OUString Outliner::GetText( Paragraph const * pParagraph, sal_Int32 nCount ) const
|
||||
{
|
||||
|
||||
OUStringBuffer aText;
|
||||
OUStringBuffer aText(128);
|
||||
sal_Int32 nStartPara = pParaList->GetAbsPos( pParagraph );
|
||||
for ( sal_Int32 n = 0; n < nCount; n++ )
|
||||
{
|
||||
|
||||
@@ -132,8 +132,8 @@ class XMLOFF_DLLPUBLIC SvXMLNumFormatContext : public SvXMLStyleContext
|
||||
bool bAutoDec; // set in AddNumber
|
||||
bool bAutoInt; // set in AddNumber
|
||||
bool bHasExtraText;
|
||||
OUStringBuffer aFormatCode;
|
||||
OUStringBuffer aConditions;
|
||||
OUStringBuffer aFormatCode{64};
|
||||
OUStringBuffer aConditions{32};
|
||||
bool bHasLongDoW;
|
||||
bool bHasEra;
|
||||
bool bHasDateTime;
|
||||
|
||||
@@ -119,6 +119,9 @@ public:
|
||||
void convertMeasureToXML( OUStringBuffer& rBuffer,
|
||||
sal_Int32 nMeasure ) const;
|
||||
|
||||
/** convert measure to string: from meCoreMeasureUnit to meXMLMeasureUnit */
|
||||
OUString convertMeasureToXML( sal_Int32 nMeasure ) const;
|
||||
|
||||
/** convert string to enum using given enum map, if the enum is
|
||||
not found in the map, this method will return false */
|
||||
template<typename EnumT>
|
||||
|
||||
@@ -45,12 +45,10 @@ namespace {
|
||||
OUString lclGetRelationsPath( const OUString& rFragmentPath )
|
||||
{
|
||||
sal_Int32 nPathLen = ::std::max< sal_Int32 >( rFragmentPath.lastIndexOf( '/' ) + 1, 0 );
|
||||
return
|
||||
OUStringBuffer( rFragmentPath.copy( 0, nPathLen ) ). // file path including slash
|
||||
append( "_rels/" ). // additional '_rels/' path
|
||||
append( std::u16string_view(rFragmentPath).substr(nPathLen) ). // file name after path
|
||||
append( ".rels" ). // '.rels' suffix
|
||||
makeStringAndClear();
|
||||
return rtl::OUStringView(rFragmentPath.getStr(), nPathLen ) + // file path including slash
|
||||
"_rels/" + // additional '_rels/' path
|
||||
rtl::OUStringView(rFragmentPath.getStr() + nPathLen) + // file name after path
|
||||
".rels"; // '.rels' suffix
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -261,7 +261,7 @@ void OleHelper::exportGuid( BinaryOutputStream& rOStr, const SvGlobalName& rId )
|
||||
|
||||
OUString OleHelper::importGuid( BinaryInputStream& rInStrm )
|
||||
{
|
||||
OUStringBuffer aBuffer;
|
||||
OUStringBuffer aBuffer(40);
|
||||
aBuffer.append( '{' );
|
||||
lclAppendHex( aBuffer, rInStrm.readuInt32() );
|
||||
aBuffer.append( '-' );
|
||||
|
||||
@@ -143,7 +143,7 @@ void VbaModule::createEmptyModule( const Reference< container::XNameContainer >&
|
||||
|
||||
OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const
|
||||
{
|
||||
OUStringBuffer aSourceCode;
|
||||
OUStringBuffer aSourceCode(512);
|
||||
static const char sUnmatchedRemovedTag[] = "Rem removed unmatched Sub/End: ";
|
||||
if( !maStreamName.isEmpty() && (mnOffset != SAL_MAX_UINT32) )
|
||||
{
|
||||
@@ -264,7 +264,7 @@ void VbaModule::createModule( const OUString& rVBASourceCode,
|
||||
// prepare the Basic module
|
||||
script::ModuleInfo aModuleInfo;
|
||||
aModuleInfo.ModuleType = mnType;
|
||||
OUStringBuffer aSourceCode;
|
||||
OUStringBuffer aSourceCode(512);
|
||||
aSourceCode.append( "Rem Attribute VBA_ModuleType=" );
|
||||
switch( mnType )
|
||||
{
|
||||
|
||||
@@ -193,7 +193,7 @@ bool ScCalcConfig::operator!= (const ScCalcConfig& r) const
|
||||
|
||||
OUString ScOpCodeSetToSymbolicString(const ScCalcConfig::OpCodeSet& rOpCodes)
|
||||
{
|
||||
OUStringBuffer result;
|
||||
OUStringBuffer result(256);
|
||||
formula::FormulaCompiler aCompiler;
|
||||
formula::FormulaCompiler::OpCodeMapPtr pOpCodeMap(aCompiler.GetOpCodeMap(css::sheet::FormulaLanguage::ENGLISH));
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ ScUserList::ScUserList()
|
||||
xCal = rCalendar.Days;
|
||||
if ( xCal.hasElements() )
|
||||
{
|
||||
OUStringBuffer aDayShortBuf, aDayLongBuf;
|
||||
OUStringBuffer aDayShortBuf(32), aDayLongBuf(64);
|
||||
sal_Int32 i;
|
||||
sal_Int32 nLen = xCal.getLength();
|
||||
sal_Int16 nStart = sal::static_int_cast<sal_Int16>(nLen);
|
||||
@@ -244,7 +244,7 @@ ScUserList::ScUserList()
|
||||
xCal = rCalendar.Months;
|
||||
if ( xCal.hasElements() )
|
||||
{
|
||||
OUStringBuffer aMonthShortBuf, aMonthLongBuf;
|
||||
OUStringBuffer aMonthShortBuf(128), aMonthLongBuf(128);
|
||||
sal_Int32 i;
|
||||
sal_Int32 nLen = xCal.getLength() - 1;
|
||||
for (i = 0; i < nLen; i++)
|
||||
|
||||
@@ -224,17 +224,15 @@ void XclImpPageSettings::Finalize()
|
||||
|
||||
// *** create page style sheet ***
|
||||
|
||||
OUStringBuffer aStyleName;
|
||||
aStyleName.append("PageStyle_");
|
||||
|
||||
OUString aStyleName;
|
||||
OUString aTableName;
|
||||
if( GetDoc().GetName( nScTab, aTableName ) )
|
||||
aStyleName.append(aTableName);
|
||||
aStyleName = "PageStyle_" + aTableName;
|
||||
else
|
||||
aStyleName.append(static_cast<sal_Int32>(nScTab+1));
|
||||
aStyleName = "PageStyle_" + OUString::number(static_cast<sal_Int32>(nScTab+1));
|
||||
|
||||
ScStyleSheet& rStyleSheet = ScfTools::MakePageStyleSheet(
|
||||
GetStyleSheetPool(), aStyleName.makeStringAndClear(), false);
|
||||
GetStyleSheetPool(), aStyleName, false);
|
||||
|
||||
SfxItemSet& rItemSet = rStyleSheet.GetItemSet();
|
||||
|
||||
|
||||
@@ -831,7 +831,7 @@ std::size_t XclImpStream::ReadUniStringExtHeader( bool& rb16Bit, sal_uInt8 nFlag
|
||||
|
||||
OUString XclImpStream::ReadRawUniString( sal_uInt16 nChars, bool b16Bit )
|
||||
{
|
||||
OUStringBuffer aRet;
|
||||
OUStringBuffer aRet(nChars);
|
||||
sal_uInt16 nCharsLeft = nChars;
|
||||
sal_uInt16 nReadSize;
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class ScXMLTableRowCellContext : public ScXMLImportContext
|
||||
boost::optional<OUString> maFirstParagraph; /// unformatted first paragraph, for better performance.
|
||||
|
||||
ScEditEngineDefaulter* mpEditEngine;
|
||||
OUStringBuffer maParagraph;
|
||||
OUStringBuffer maParagraph{32};
|
||||
sal_Int32 mnCurParagraph;
|
||||
|
||||
ParaFormatsType maFormats;
|
||||
|
||||
@@ -452,7 +452,7 @@ void LinkManager::InsertFileLink(
|
||||
if (!(OBJECT_CLIENT_SO & rLink.GetObjType()))
|
||||
return;
|
||||
|
||||
OUStringBuffer aBuf;
|
||||
OUStringBuffer aBuf(64);
|
||||
aBuf.append(rFileNm);
|
||||
aBuf.append(sfx2::cTokenSeparator);
|
||||
|
||||
|
||||
@@ -509,7 +509,7 @@ dateTimeToText(css::util::DateTime const& i_rdt,
|
||||
sal_Int16 const*const pTimeZone = nullptr) throw ()
|
||||
{
|
||||
if (isValidDateTime(i_rdt)) {
|
||||
OUStringBuffer buf;
|
||||
OUStringBuffer buf(32);
|
||||
::sax::Converter::convertDateTime(buf, i_rdt, pTimeZone, true);
|
||||
return buf.makeStringAndClear();
|
||||
} else {
|
||||
|
||||
@@ -213,7 +213,7 @@ void SfxLokHelper::notifyWindow(const SfxViewShell* pThisView,
|
||||
|
||||
void SfxLokHelper::notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload)
|
||||
{
|
||||
OStringBuffer aBuf;
|
||||
OStringBuffer aBuf(32);
|
||||
aBuf.append(rPayload);
|
||||
if (comphelper::LibreOfficeKit::isPartInInvalidation())
|
||||
{
|
||||
|
||||
@@ -1647,7 +1647,7 @@ short SvNumberformat::ImpNextSymbol(OUStringBuffer& rString,
|
||||
sal_Unicode cLetter = ' '; // Preliminary result
|
||||
sal_Int32 nLen = rString.getLength();
|
||||
ScanState eState = SsStart;
|
||||
OUStringBuffer sBuffSymbol(64);
|
||||
OUStringBuffer sBuffSymbol(128);
|
||||
|
||||
const NfKeywordTable & rKeywords = rScan.GetKeywords();
|
||||
while (nPos < nLen && eState != SsStop)
|
||||
|
||||
@@ -398,7 +398,7 @@ static void exceptionToStringImpl(OStringBuffer& sMessage, const css::uno::Any &
|
||||
|
||||
OString exceptionToString(const css::uno::Any & caught)
|
||||
{
|
||||
OStringBuffer sMessage;
|
||||
OStringBuffer sMessage(512);
|
||||
exceptionToStringImpl(sMessage, caught);
|
||||
return sMessage.makeStringAndClear();
|
||||
}
|
||||
|
||||
@@ -1369,7 +1369,7 @@ bool INetURLObject::setAbsURIRef(OUString const & rTheAbsURIRef,
|
||||
}
|
||||
break;
|
||||
}
|
||||
OUStringBuffer aSynHost;
|
||||
OUStringBuffer aSynHost(64);
|
||||
if (!parseHostOrNetBiosName(
|
||||
pHostPortBegin, pPort, eMechanism, eCharset,
|
||||
bNetBiosName, &aSynHost))
|
||||
@@ -1614,7 +1614,7 @@ bool INetURLObject::convertRelToAbs(OUString const & rTheRelURIRef,
|
||||
enum State { STATE_AUTH, STATE_ABS_PATH, STATE_REL_PATH, STATE_FRAGMENT,
|
||||
STATE_DONE };
|
||||
|
||||
OUStringBuffer aSynAbsURIRef;
|
||||
OUStringBuffer aSynAbsURIRef(128);
|
||||
// make sure that the scheme is copied for generic schemes: getSchemeInfo().m_pScheme
|
||||
// is empty ("") in that case, so take the scheme from m_aAbsURIRef
|
||||
if (m_eScheme != INetProtocol::Generic)
|
||||
@@ -2342,7 +2342,7 @@ bool INetURLObject::parseHost(sal_Unicode const *& rBegin, sal_Unicode const * p
|
||||
STATE_IP6_HEXSEQ1_MAYBE_IP4, STATE_IP6_HEXSEQ2,
|
||||
STATE_IP6_HEXSEQ2_COLON, STATE_IP6_HEXSEQ2_MAYBE_IP4,
|
||||
STATE_IP6_IP4, STATE_IP6_IP4_DOT, STATE_IP6_DONE };
|
||||
OUStringBuffer aTheCanonic;
|
||||
OUStringBuffer aTheCanonic(32);
|
||||
sal_uInt32 nNumber = 0;
|
||||
int nDigits = 0;
|
||||
int nOctets = 0;
|
||||
@@ -4320,7 +4320,7 @@ OUString INetURLObject::getFSysPath(FSysStyle eStyle,
|
||||
if (pDelimiter)
|
||||
*pDelimiter = '\\';
|
||||
|
||||
OUStringBuffer aSynFSysPath;
|
||||
OUStringBuffer aSynFSysPath(64);
|
||||
if (m_aHost.isPresent() && m_aHost.getLength() > 0)
|
||||
{
|
||||
aSynFSysPath.append("\\\\");
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace utl
|
||||
|
||||
OUString DocInfoHelper::GetGeneratorString()
|
||||
{
|
||||
OUStringBuffer aResult;
|
||||
OUStringBuffer aResult(128);
|
||||
|
||||
// First product: branded name + version
|
||||
// version is <product_versions>_<product_extension>$<platform>
|
||||
|
||||
@@ -259,7 +259,7 @@ void typeConvert(const css::util::DateTime& _rDateTime, DateTime& _rOut)
|
||||
|
||||
OUString toISO8601(const css::util::DateTime& rDateTime)
|
||||
{
|
||||
OUStringBuffer rBuffer;
|
||||
OUStringBuffer rBuffer(32);
|
||||
rBuffer.append(static_cast<sal_Int32>(rDateTime.Year));
|
||||
rBuffer.append('-');
|
||||
if( rDateTime.Month < 10 )
|
||||
|
||||
@@ -167,9 +167,10 @@ OString GraphicID::getIDString() const
|
||||
{
|
||||
static const char aHexData[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
||||
|
||||
OStringBuffer aHexStr;
|
||||
sal_Int32 nShift, nIndex = 0;
|
||||
aHexStr.setLength(24 + (2 * BITMAP_CHECKSUM_SIZE));
|
||||
sal_Int32 nLen = 24 + (2 * BITMAP_CHECKSUM_SIZE);
|
||||
OStringBuffer aHexStr(nLen);
|
||||
aHexStr.setLength(nLen);
|
||||
|
||||
for( nShift = 28; nShift >= 0; nShift -= 4 )
|
||||
aHexStr[nIndex++] = aHexData[ ( mnID1 >> static_cast<sal_uInt32>(nShift) ) & 0xf ];
|
||||
|
||||
@@ -309,7 +309,8 @@ OUString StringMapToOUString(const std::map<OUString, OUString>& rParameters)
|
||||
if (rParameters.empty())
|
||||
return "";
|
||||
|
||||
OUStringBuffer aParameterString = " {";
|
||||
OUStringBuffer aParameterString(static_cast<int>(rParameters.size()*32));
|
||||
aParameterString.append(" {");
|
||||
|
||||
for (std::map<OUString, OUString>::const_iterator itr = rParameters.begin();
|
||||
itr != rParameters.end(); ++itr)
|
||||
|
||||
@@ -185,6 +185,16 @@ void SvXMLUnitConverter::convertMeasureToXML( OUStringBuffer& rString,
|
||||
m_pImpl->m_eXMLMeasureUnit );
|
||||
}
|
||||
|
||||
/** convert measure to string */
|
||||
OUString SvXMLUnitConverter::convertMeasureToXML( sal_Int32 nMeasure ) const
|
||||
{
|
||||
OUStringBuffer s;
|
||||
::sax::Converter::convertMeasure( s, nMeasure,
|
||||
m_pImpl->m_eCoreMeasureUnit,
|
||||
m_pImpl->m_eXMLMeasureUnit );
|
||||
return s.makeStringAndClear();
|
||||
}
|
||||
|
||||
/** convert string to enum using given enum map, if the enum is
|
||||
not found in the map, this method will return false
|
||||
*/
|
||||
@@ -733,7 +743,7 @@ OUString SvXMLUnitConverter::encodeStyleName(
|
||||
*pEncoded = false;
|
||||
|
||||
sal_Int32 nLen = rName.getLength();
|
||||
OUStringBuffer aBuffer( nLen );
|
||||
OUStringBuffer aBuffer( nLen*2 );
|
||||
|
||||
for( sal_Int32 i = 0; i < nLen; i++ )
|
||||
{
|
||||
|
||||
@@ -344,31 +344,26 @@ void SvxXMLNumRuleExport::exportLevelStyle( sal_Int32 nLevel,
|
||||
SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, eElem,
|
||||
true, true );
|
||||
|
||||
OUStringBuffer sBuffer;
|
||||
if ( ePosAndSpaceMode == PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION )
|
||||
{
|
||||
nSpaceBefore += nMinLabelWidth;
|
||||
nMinLabelWidth = -nMinLabelWidth;
|
||||
if( nSpaceBefore != 0 )
|
||||
{
|
||||
GetExport().GetMM100UnitConverter().convertMeasureToXML(
|
||||
sBuffer, nSpaceBefore );
|
||||
GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_SPACE_BEFORE,
|
||||
sBuffer.makeStringAndClear() );
|
||||
OUString sAttr = GetExport().GetMM100UnitConverter().convertMeasureToXML(
|
||||
nSpaceBefore );
|
||||
GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_SPACE_BEFORE, sAttr );
|
||||
}
|
||||
if( nMinLabelWidth != 0 )
|
||||
{
|
||||
GetExport().GetMM100UnitConverter().convertMeasureToXML(
|
||||
sBuffer, nMinLabelWidth );
|
||||
GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_MIN_LABEL_WIDTH,
|
||||
sBuffer.makeStringAndClear() );
|
||||
OUString s = GetExport().GetMM100UnitConverter().convertMeasureToXML( nMinLabelWidth );
|
||||
GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_MIN_LABEL_WIDTH, s);
|
||||
}
|
||||
if( nMinLabelDist > 0 )
|
||||
{
|
||||
GetExport().GetMM100UnitConverter().convertMeasureToXML(
|
||||
sBuffer, nMinLabelDist );
|
||||
GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_MIN_LABEL_DISTANCE,
|
||||
sBuffer.makeStringAndClear() );
|
||||
OUString sAttr = GetExport().GetMM100UnitConverter().convertMeasureToXML(
|
||||
nMinLabelDist );
|
||||
GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_MIN_LABEL_DISTANCE, sAttr);
|
||||
}
|
||||
}
|
||||
/* Check, if properties for position-and-space-mode LABEL_ALIGNMENT
|
||||
@@ -443,18 +438,16 @@ void SvxXMLNumRuleExport::exportLevelStyle( sal_Int32 nLevel,
|
||||
|
||||
if( nImageWidth > 0 )
|
||||
{
|
||||
GetExport().GetMM100UnitConverter().convertMeasureToXML(
|
||||
sBuffer, nImageWidth );
|
||||
GetExport().AddAttribute( XML_NAMESPACE_FO, XML_WIDTH,
|
||||
sBuffer.makeStringAndClear() );
|
||||
OUString sAttr = GetExport().GetMM100UnitConverter().convertMeasureToXML(
|
||||
nImageWidth );
|
||||
GetExport().AddAttribute( XML_NAMESPACE_FO, XML_WIDTH, sAttr );
|
||||
}
|
||||
|
||||
if( nImageHeight > 0 )
|
||||
{
|
||||
GetExport().GetMM100UnitConverter().convertMeasureToXML(
|
||||
sBuffer, nImageHeight );
|
||||
GetExport().AddAttribute( XML_NAMESPACE_FO, XML_HEIGHT,
|
||||
sBuffer.makeStringAndClear() );
|
||||
OUString sAttr = GetExport().GetMM100UnitConverter().convertMeasureToXML(
|
||||
nImageHeight );
|
||||
GetExport().AddAttribute( XML_NAMESPACE_FO, XML_HEIGHT, sAttr );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -490,29 +483,29 @@ void SvxXMLNumRuleExport::exportLevelStyle( sal_Int32 nLevel,
|
||||
if ( eLabelFollowedBy == LabelFollow::LISTTAB &&
|
||||
nListtabStopPosition > 0 )
|
||||
{
|
||||
GetExport().GetMM100UnitConverter().convertMeasureToXML(
|
||||
sBuffer, nListtabStopPosition );
|
||||
OUString sAttr = GetExport().GetMM100UnitConverter().convertMeasureToXML(
|
||||
nListtabStopPosition );
|
||||
GetExport().AddAttribute( XML_NAMESPACE_TEXT,
|
||||
XML_LIST_TAB_STOP_POSITION,
|
||||
sBuffer.makeStringAndClear() );
|
||||
sAttr );
|
||||
}
|
||||
|
||||
if ( nFirstLineIndent != 0 )
|
||||
{
|
||||
GetExport().GetMM100UnitConverter().convertMeasureToXML(
|
||||
sBuffer, nFirstLineIndent );
|
||||
OUString sAttr = GetExport().GetMM100UnitConverter().convertMeasureToXML(
|
||||
nFirstLineIndent );
|
||||
GetExport().AddAttribute( XML_NAMESPACE_FO,
|
||||
XML_TEXT_INDENT,
|
||||
sBuffer.makeStringAndClear() );
|
||||
sAttr );
|
||||
}
|
||||
|
||||
if ( nIndentAt != 0 )
|
||||
{
|
||||
GetExport().GetMM100UnitConverter().convertMeasureToXML(
|
||||
sBuffer, nIndentAt );
|
||||
OUString sAttr = GetExport().GetMM100UnitConverter().convertMeasureToXML(
|
||||
nIndentAt );
|
||||
GetExport().AddAttribute( XML_NAMESPACE_FO,
|
||||
XML_MARGIN_LEFT,
|
||||
sBuffer.makeStringAndClear() );
|
||||
sAttr );
|
||||
}
|
||||
|
||||
SvXMLElementExport aLabelAlignmentElement( GetExport(), XML_NAMESPACE_STYLE,
|
||||
@@ -582,6 +575,7 @@ void SvxXMLNumRuleExport::exportLevelStyle( sal_Int32 nLevel,
|
||||
}
|
||||
else
|
||||
{
|
||||
OUStringBuffer sBuffer;
|
||||
::sax::Converter::convertColor( sBuffer, nColor );
|
||||
GetExport().AddAttribute( XML_NAMESPACE_FO, XML_COLOR,
|
||||
sBuffer.makeStringAndClear() );
|
||||
|
||||
Reference in New Issue
Block a user