summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2019-10-17 20:33:50 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-10-21 08:36:01 +0200
commit0f874472c672175135520101837ff0c9d4701d7f (patch)
treefa6a504bdfc7d5d838caed7cfb87793321797290
parent9112c18524c9f5e67d6cbb282586a439e3020cdb (diff)
size some stringbuffer to prevent re-alloc
found by the simple expidient of putting asserts in the resize routine. Where an explicit const size is used, I started with 32 and kept doubling until that site did not need resizing anymore. Change-Id: I998787edc940d0a3ba23b5ac37131ab9ecd300f4 Reviewed-on: https://gerrit.libreoffice.org/81138 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--codemaker/source/cppumaker/cpputype.cxx6
-rw-r--r--configmgr/source/childaccess.cxx2
-rw-r--r--configmgr/source/data.cxx7
-rw-r--r--configmgr/source/xcsparser.cxx2
-rw-r--r--configmgr/source/xcuparser.cxx2
-rw-r--r--desktop/source/deployment/misc/dp_misc.cxx4
-rw-r--r--framework/source/accelerators/storageholder.cxx2
-rw-r--r--framework/source/fwi/classes/protocolhandlercache.cxx12
-rw-r--r--framework/source/services/substitutepathvars.cxx2
-rw-r--r--framework/source/services/urltransformer.cxx2
-rw-r--r--framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx17
-rw-r--r--framework/source/uiconfiguration/uiconfigurationmanager.cxx17
-rw-r--r--i18npool/source/localedata/localedata.cxx29
-rw-r--r--idl/source/cmptools/lex.cxx4
-rw-r--r--idl/source/objects/object.cxx3
-rw-r--r--idl/source/objects/types.cxx2
-rw-r--r--idl/source/prj/database.cxx2
-rw-r--r--include/xmlreader/pad.hxx2
-rw-r--r--sal/Module_sal.mk1
-rw-r--r--sal/osl/unx/file_url.cxx9
-rw-r--r--sal/osl/unx/tempfile.cxx12
-rw-r--r--sal/rtl/bootstrap.cxx6
-rw-r--r--sal/rtl/uri.cxx4
-rw-r--r--stoc/source/inspect/introspection.cxx2
-rw-r--r--stoc/source/uriproc/ExternalUriReferenceTranslator.cxx4
-rw-r--r--stoc/source/uriproc/UriReference.cxx2
-rw-r--r--stoc/source/uriproc/UriReferenceFactory.cxx7
-rw-r--r--stoc/source/uriproc/UriSchemeParser_vndDOTsunDOTstarDOTscript.cxx9
-rw-r--r--stoc/source/uriproc/VndSunStarPkgUrlReferenceFactory.cxx2
-rw-r--r--stoc/test/uriproc/test_uriproc.cxx2
-rw-r--r--svl/source/numbers/zforlist.cxx29
-rw-r--r--svl/source/numbers/zformat.cxx4
-rw-r--r--svx/source/gengal/gengal.cxx2
-rw-r--r--tools/source/fsys/urlobj.cxx25
-rw-r--r--tools/source/inet/inetmime.cxx4
-rw-r--r--tools/source/misc/extendapplicationenvironment.cxx2
-rw-r--r--ucb/source/core/ucb.cxx2
-rw-r--r--ucb/source/ucp/inc/urihelper.hxx2
-rw-r--r--ucb/source/ucp/webdav-neon/NeonUri.cxx3
-rw-r--r--unoidl/source/sourceprovider-parser.y3
-rw-r--r--unotools/source/config/pathoptions.cxx2
-rw-r--r--vcl/source/window/syswin.cxx2
-rw-r--r--xmloff/source/draw/xexptran.cxx2
43 files changed, 131 insertions, 128 deletions
diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx
index 67b842f0c3d1..a16256d4c353 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -1004,7 +1004,7 @@ OUString CppuType::resolveAllTypedefs(OUString const & name) const
u2b(dynamic_cast<unoidl::TypedefEntity&>(*ent).getType()), &k2));
k1 += k2; //TODO: overflow
}
- OUStringBuffer b;
+ OUStringBuffer b(k1*2 + n.getLength());
for (sal_Int32 i = 0; i != k1; ++i) {
b.append("[]");
}
@@ -2675,7 +2675,7 @@ OUString typeToIdentifier(OUString const & name)
{
sal_Int32 k;
OUString n(b2u(codemaker::UnoType::decompose(u2b(name), &k)));
- OUStringBuffer b;
+ OUStringBuffer b(4*k + n.getLength());
for (sal_Int32 i = 0; i != k; ++i) {
b.append("seq_");
}
@@ -3587,7 +3587,7 @@ void ServiceType::dumpHppFile(
for (const unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter& param :
cons.parameters) {
o << ", ";
- OUStringBuffer buf;
+ OUStringBuffer buf(2 + param.type.getLength());
if (param.rest) {
buf.append("[]");
}
diff --git a/configmgr/source/childaccess.cxx b/configmgr/source/childaccess.cxx
index 82ca003c1703..68bc0b01351c 100644
--- a/configmgr/source/childaccess.cxx
+++ b/configmgr/source/childaccess.cxx
@@ -104,7 +104,7 @@ std::vector<OUString> ChildAccess::getRelativePath() {
}
OUString ChildAccess::getRelativePathRepresentation() {
- OUStringBuffer path;
+ OUStringBuffer path(128);
rtl::Reference< Access > parent(getParentAccess());
if (parent.is()) {
path.append(parent->getRelativePathRepresentation());
diff --git a/configmgr/source/data.cxx b/configmgr/source/data.cxx
index 7ff344650ebc..4f91d3b25612 100644
--- a/configmgr/source/data.cxx
+++ b/configmgr/source/data.cxx
@@ -49,7 +49,7 @@ bool decode(
assert(
begin >= 0 && begin <= end && end <= encoded.getLength() &&
decoded != nullptr);
- OUStringBuffer buf;
+ OUStringBuffer buf(end - begin);
while (begin != end) {
sal_Unicode c = encoded[begin++];
if (c == '&') {
@@ -82,7 +82,8 @@ OUString Data::createSegment(
if (templateName.isEmpty()) {
return name;
}
- OUStringBuffer buf(templateName);
+ OUStringBuffer buf(128);
+ buf.append(templateName);
//TODO: verify template name contains no bad chars?
buf.append("['");
for (sal_Int32 i = 0; i < name.getLength(); ++i) {
@@ -207,7 +208,7 @@ rtl::Reference< Node > Data::resolvePathRepresentation(
}
NodeMap const & components = getComponents();
NodeMap::const_iterator i(components.find(seg));
- OUStringBuffer canonic;
+ OUStringBuffer canonic(128);
rtl::Reference< Node > parent;
int finalized = NO_LAYER;
for (rtl::Reference< Node > p(i == components.end() ? nullptr : i->second);;) {
diff --git a/configmgr/source/xcsparser.cxx b/configmgr/source/xcsparser.cxx
index 24e1dc008312..c0b34974157b 100644
--- a/configmgr/source/xcsparser.cxx
+++ b/configmgr/source/xcsparser.cxx
@@ -321,7 +321,7 @@ void XcsParser::characters(xmlreader::Span const & text) {
void XcsParser::handleComponentSchema(xmlreader::XmlReader & reader) {
//TODO: oor:version, xml:lang attributes
- OStringBuffer buf;
+ OStringBuffer buf(256);
buf.append('.');
bool hasPackage = false;
bool hasName = false;
diff --git a/configmgr/source/xcuparser.cxx b/configmgr/source/xcuparser.cxx
index 89508be97992..03e3c60ab067 100644
--- a/configmgr/source/xcuparser.cxx
+++ b/configmgr/source/xcuparser.cxx
@@ -220,7 +220,7 @@ XcuParser::Operation XcuParser::parseOperation(xmlreader::Span const & text) {
}
void XcuParser::handleComponentData(xmlreader::XmlReader & reader) {
- OStringBuffer buf;
+ OStringBuffer buf(256);
buf.append('.');
bool hasPackage = false;
bool hasName = false;
diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx
index a23855109c36..7b4aafb3b083 100644
--- a/desktop/source/deployment/misc/dp_misc.cxx
+++ b/desktop/source/deployment/misc/dp_misc.cxx
@@ -243,7 +243,7 @@ namespace {
OUString encodeForRcFile( OUString const & str )
{
// escape $\{} (=> rtl bootstrap files)
- OUStringBuffer buf;
+ OUStringBuffer buf(64);
sal_Int32 pos = 0;
const sal_Int32 len = str.getLength();
for ( ; pos < len; ++pos ) {
@@ -265,7 +265,7 @@ OUString encodeForRcFile( OUString const & str )
OUString makeURL( OUString const & baseURL, OUString const & relPath_ )
{
- OUStringBuffer buf;
+ OUStringBuffer buf(128);
if (baseURL.getLength() > 1 && baseURL[ baseURL.getLength() - 1 ] == '/')
buf.append( std::u16string_view(baseURL).substr(0, baseURL.getLength() - 1) );
else
diff --git a/framework/source/accelerators/storageholder.cxx b/framework/source/accelerators/storageholder.cxx
index 567c7af65220..d12a13fbc47a 100644
--- a/framework/source/accelerators/storageholder.cxx
+++ b/framework/source/accelerators/storageholder.cxx
@@ -354,7 +354,7 @@ css::uno::Reference< css::embed::XStorage > StorageHolder::getParentStorage(cons
return m_xRoot;
// c)
- OUStringBuffer sParentPath;
+ OUStringBuffer sParentPath(64);
sal_Int32 i = 0;
for (i = 0; i < c - 1; ++i)
{
diff --git a/framework/source/fwi/classes/protocolhandlercache.cxx b/framework/source/fwi/classes/protocolhandlercache.cxx
index 8a27747bcb48..40e938e04c32 100644
--- a/framework/source/fwi/classes/protocolhandlercache.cxx
+++ b/framework/source/fwi/classes/protocolhandlercache.cxx
@@ -200,13 +200,13 @@ void HandlerCFGAccess::read( HandlerHash& rHandlerHash, PatternHash& rPatternHas
sal_Int32 nTarget=0;
for( nSource=0; nSource<nSourceCount; ++nSource )
{
- OUStringBuffer sPath( SETNAME_HANDLER );
- sPath.append(CFG_PATH_SEPARATOR);
- sPath.append(lNames[nSource]);
- sPath.append(CFG_PATH_SEPARATOR);
- sPath.append(PROPERTY_PROTOCOLS);
+ lFullNames[nTarget] =
+ SETNAME_HANDLER
+ CFG_PATH_SEPARATOR +
+ lNames[nSource] +
+ CFG_PATH_SEPARATOR
+ PROPERTY_PROTOCOLS;
- lFullNames[nTarget] = sPath.makeStringAndClear();
++nTarget;
}
diff --git a/framework/source/services/substitutepathvars.cxx b/framework/source/services/substitutepathvars.cxx
index 97c91ea9f9d3..3c5733d47a1b 100644
--- a/framework/source/services/substitutepathvars.cxx
+++ b/framework/source/services/substitutepathvars.cxx
@@ -286,7 +286,7 @@ OUString SubstitutePathVariables::GetPathVariableValue() const
if ( pEnv )
{
- const int PATH_EXTEND_FACTOR = 120;
+ const int PATH_EXTEND_FACTOR = 200;
OUString aTmp;
OUString aPathList( pEnv, strlen( pEnv ), osl_getThreadTextEncoding() );
OUStringBuffer aPathStrBuffer( aPathList.getLength() * PATH_EXTEND_FACTOR / 100 );
diff --git a/framework/source/services/urltransformer.cxx b/framework/source/services/urltransformer.cxx
index ce9ae752ec60..23a314026588 100644
--- a/framework/source/services/urltransformer.cxx
+++ b/framework/source/services/urltransformer.cxx
@@ -76,7 +76,7 @@ void lcl_ParserHelper(INetURLObject& _rParser, css::util::URL& _rURL,bool _bUseI
// Don't add last segment as it is the name!
--nCount;
- OUStringBuffer aPath;
+ OUStringBuffer aPath(128);
for ( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
{
aPath.append( '/');
diff --git a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
index 36631222539e..691c4b69a794 100644
--- a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
@@ -222,7 +222,7 @@ private:
// important: The order and position of the elements must match the constant
// definition of "css::ui::UIElementType"
-static const char* UIELEMENTTYPENAMES[] =
+static OUStringLiteral UIELEMENTTYPENAMES[] =
{
"", // Dummy value for unknown!
UIELEMENTTYPE_MENUBAR_NAME,
@@ -250,7 +250,7 @@ sal_Int16 RetrieveTypeFromResourceURL( const OUString& aResourceURL )
OUString aTypeStr( aTmpStr.copy( 0, nIndex ));
for ( int i = 0; i < ui::UIElementType::COUNT; i++ )
{
- if ( aTypeStr.equalsAscii( UIELEMENTTYPENAMES[i] ))
+ if ( aTypeStr == UIELEMENTTYPENAMES[i] )
return sal_Int16( i );
}
}
@@ -358,11 +358,10 @@ void ModuleUIConfigurationManager::impl_preloadUIElementTypeList( Layer eLayer,
Reference< XStorage > xElementTypeStorage = rElementTypeData.xStorage;
if ( xElementTypeStorage.is() )
{
- OUStringBuffer aBuf( RESOURCEURL_PREFIX_SIZE );
- aBuf.append( RESOURCEURL_PREFIX );
- aBuf.appendAscii( UIELEMENTTYPENAMES[ nElementType ] );
- aBuf.append( "/" );
- OUString aResURLPrefix( aBuf.makeStringAndClear() );
+ OUString aResURLPrefix =
+ RESOURCEURL_PREFIX +
+ UIELEMENTTYPENAMES[ nElementType ] +
+ "/";
UIElementDataHashMap& rHashMap = rElementTypeData.aElementsHashMap;
Sequence< OUString > aUIElementNames = xElementTypeStorage->getElementNames();
@@ -808,7 +807,7 @@ void ModuleUIConfigurationManager::impl_Initialize()
Reference< XStorage > xElementTypeStorage;
try
{
- const OUString sName( OUString::createFromAscii( UIELEMENTTYPENAMES[i] ) );
+ const OUString sName( UIELEMENTTYPENAMES[i] );
if( xNameAccess->hasByName( sName ) )
xNameAccess->getByName( sName ) >>= xElementTypeStorage;
}
@@ -1583,7 +1582,7 @@ void SAL_CALL ModuleUIConfigurationManager::storeToStorage( const Reference< XSt
try
{
Reference< XStorage > xElementTypeStorage( Storage->openStorageElement(
- OUString::createFromAscii( UIELEMENTTYPENAMES[i] ), ElementModes::READWRITE ));
+ UIELEMENTTYPENAMES[i], ElementModes::READWRITE ));
UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][i];
if ( rElementType.bModified && xElementTypeStorage.is() )
diff --git a/framework/source/uiconfiguration/uiconfigurationmanager.cxx b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
index 9f309f7d7656..778028f98d42 100644
--- a/framework/source/uiconfiguration/uiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
@@ -197,7 +197,7 @@ private:
// important: The order and position of the elements must match the constant
// definition of "css::ui::UIElementType"
-static const char* UIELEMENTTYPENAMES[] =
+static OUStringLiteral UIELEMENTTYPENAMES[] =
{
"", // Dummy value for unknown!
UIELEMENTTYPE_MENUBAR_NAME,
@@ -225,7 +225,7 @@ sal_Int16 RetrieveTypeFromResourceURL( const OUString& aResourceURL )
OUString aTypeStr( aTmpStr.copy( 0, nIndex ));
for ( int i = 0; i < UIElementType::COUNT; i++ )
{
- if ( aTypeStr.equalsAscii( UIELEMENTTYPENAMES[i] ))
+ if ( aTypeStr == UIELEMENTTYPENAMES[i] )
return sal_Int16( i );
}
}
@@ -283,11 +283,10 @@ void UIConfigurationManager::impl_preloadUIElementTypeList( sal_Int16 nElementTy
Reference< XStorage > xElementTypeStorage = rElementTypeData.xStorage;
if ( xElementTypeStorage.is() )
{
- OUStringBuffer aBuf( RESOURCEURL_PREFIX_SIZE );
- aBuf.append( RESOURCEURL_PREFIX );
- aBuf.appendAscii( UIELEMENTTYPENAMES[ nElementType ] );
- aBuf.append( "/" );
- OUString aResURLPrefix( aBuf.makeStringAndClear() );
+ OUString aResURLPrefix =
+ RESOURCEURL_PREFIX +
+ UIELEMENTTYPENAMES[ nElementType ] +
+ "/";
UIElementDataHashMap& rHashMap = rElementTypeData.aElementsHashMap;
Sequence< OUString > aUIElementNames = xElementTypeStorage->getElementNames();
@@ -637,7 +636,7 @@ void UIConfigurationManager::impl_Initialize()
Reference< XStorage > xElementTypeStorage;
try
{
- xElementTypeStorage = m_xDocConfigStorage->openStorageElement( OUString::createFromAscii( UIELEMENTTYPENAMES[i] ), nModes );
+ xElementTypeStorage = m_xDocConfigStorage->openStorageElement( UIELEMENTTYPENAMES[i], nModes );
}
catch ( const css::container::NoSuchElementException& )
{
@@ -1308,7 +1307,7 @@ void SAL_CALL UIConfigurationManager::storeToStorage( const Reference< XStorage
try
{
Reference< XStorage > xElementTypeStorage( Storage->openStorageElement(
- OUString::createFromAscii( UIELEMENTTYPENAMES[i] ), ElementModes::READWRITE ));
+ UIELEMENTTYPENAMES[i], ElementModes::READWRITE ));
UIElementType& rElementType = m_aUIElements[i];
if ( rElementType.bModified && xElementTypeStorage.is() )
diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx
index 68a0d9359b47..e379b403248c 100644
--- a/i18npool/source/localedata/localedata.cxx
+++ b/i18npool/source/localedata/localedata.cxx
@@ -538,8 +538,6 @@ oslGenericFunction lcl_LookupTableHelper::getFunctionSymbolByName(
(bFallback && aFallback.equalsAscii(i.pLocale)))
{
#ifndef DISABLE_DYNLOADING
- OUStringBuffer aBuf(sal::static_int_cast<int>(
- strlen(i.pLocale) + 1 + strlen(pFunction)));
{
::osl::MutexGuard aGuard( maMutex );
for (LocaleDataLookupTableItem & rCurrent : maLookupTable)
@@ -551,9 +549,10 @@ oslGenericFunction lcl_LookupTableHelper::getFunctionSymbolByName(
{
(*pOutCachedItem).reset(new LocaleDataLookupTableItem( rCurrent ));
(*pOutCachedItem)->localeName = i.pLocale;
+ OString sSymbolName = rtl::OStringView(pFunction) + "_" +
+ (*pOutCachedItem)->localeName;
return (*pOutCachedItem)->module->getFunctionSymbol(
- aBuf.appendAscii( pFunction).append( cUnder).
- appendAscii( (*pOutCachedItem)->localeName).makeStringAndClear());
+ sSymbolName.getStr());
}
else
return nullptr;
@@ -562,14 +561,14 @@ oslGenericFunction lcl_LookupTableHelper::getFunctionSymbolByName(
}
// Library not loaded, load it and add it to the list.
#ifdef SAL_DLLPREFIX
- aBuf.ensureCapacity(strlen(i.pLib) + 6); // mostly "lib*.so"
- aBuf.append( SAL_DLLPREFIX ).appendAscii(i.pLib).append( SAL_DLLEXTENSION );
+ OString sModuleName = // mostly "lib*.so"
+ SAL_DLLPREFIX + rtl::OStringView(i.pLib) + SAL_DLLEXTENSION;
#else
- aBuf.ensureCapacity(strlen(i.pLib) + 4); // mostly "*.dll"
- aBuf.appendAscii(i.pLib).append( SAL_DLLEXTENSION );
+ OString sModuleName = // mostly "*.dll"
+ rtl::OStringView(i.pLib) + SAL_DLLEXTENSION;
#endif
std::unique_ptr<osl::Module> module(new osl::Module());
- if ( module->loadRelative(&thisModule, aBuf.makeStringAndClear()) )
+ if ( module->loadRelative(&thisModule, sModuleName.getStr()) )
{
::osl::MutexGuard aGuard( maMutex );
auto pTmpModule = module.get();
@@ -578,9 +577,8 @@ oslGenericFunction lcl_LookupTableHelper::getFunctionSymbolByName(
if( pOutCachedItem )
{
pOutCachedItem->reset(new LocaleDataLookupTableItem( maLookupTable.back() ));
- return pTmpModule->getFunctionSymbol(
- aBuf.appendAscii(pFunction).append(cUnder).
- appendAscii((*pOutCachedItem)->localeName).makeStringAndClear());
+ OString sSymbolName = rtl::OStringView(pFunction) + "_" + (*pOutCachedItem)->localeName;
+ return pTmpModule->getFunctionSymbol(sSymbolName.getStr());
}
else
return nullptr;
@@ -1444,12 +1442,11 @@ oslGenericFunction LocaleDataImpl::getFunctionSymbol( const Locale& rLocale, con
{
lcl_LookupTableHelper & rLookupTable = lcl_LookupTableStatic::get();
- OUStringBuffer aBuf(1);
if (cachedItem.get() && cachedItem->equals(rLocale))
{
- aBuf.ensureCapacity(strlen(pFunction) + 1 + strlen(cachedItem->localeName));
- return cachedItem->module->getFunctionSymbol(aBuf.appendAscii(pFunction).append(cUnder).
- appendAscii(cachedItem->localeName).makeStringAndClear());
+ OString sSymbolName = rtl::OStringView(pFunction) + "_" +
+ cachedItem->localeName;
+ return cachedItem->module->getFunctionSymbol(sSymbolName.getStr());
}
oslGenericFunction pSymbol = nullptr;
diff --git a/idl/source/cmptools/lex.cxx b/idl/source/cmptools/lex.cxx
index 599b06136008..f479bea4c4b7 100644
--- a/idl/source/cmptools/lex.cxx
+++ b/idl/source/cmptools/lex.cxx
@@ -254,7 +254,7 @@ bool SvTokenStream::MakeToken( SvToken & rToken )
}
else if( c == '"' )
{
- OStringBuffer aStr;
+ OStringBuffer aStr(128);
bool bDone = false;
while( !bDone && !IsEof() && c )
{
@@ -288,7 +288,7 @@ bool SvTokenStream::MakeToken( SvToken & rToken )
}
else if( rtl::isAsciiAlpha (static_cast<unsigned char>(c)) || (c == '_') )
{
- OStringBuffer aBuf;
+ OStringBuffer aBuf(64);
while( rtl::isAsciiAlphanumeric( static_cast<unsigned char>(c) )
|| c == '_' || c == ':')
{
diff --git a/idl/source/objects/object.cxx b/idl/source/objects/object.cxx
index 4becd0240289..a424bb748044 100644
--- a/idl/source/objects/object.cxx
+++ b/idl/source/objects/object.cxx
@@ -209,7 +209,8 @@ void SvMetaClass::InsertSlots( SvSlotElementList& rList, std::vector<sal_uLong>&
{
SvClassElement& rElement = aClassElementList[n];
SvMetaClass * pCl = rElement.GetClass();
- OStringBuffer rPre(rPrefix);
+ OStringBuffer rPre(rPrefix.getLength() + 1 + rElement.GetPrefix().getLength());
+ rPre.append(rPrefix);
if( !rPre.isEmpty() && !rElement.GetPrefix().isEmpty() )
rPre.append('.');
rPre.append(rElement.GetPrefix());
diff --git a/idl/source/objects/types.cxx b/idl/source/objects/types.cxx
index d79efe81fc43..34b0e3b78847 100644
--- a/idl/source/objects/types.cxx
+++ b/idl/source/objects/types.cxx
@@ -223,7 +223,7 @@ void SvMetaType::WriteSfxItem(
WriteStars( rOutStm );
OString aVarName = " a" + rItemName + "_Impl";
- OStringBuffer aAttrArray;
+ OStringBuffer aAttrArray(1024);
sal_uLong nAttrCount = MakeSfx( aAttrArray );
OString aAttrCount( OString::number(nAttrCount));
OString aTypeName = "SfxType" + aAttrCount;
diff --git a/idl/source/prj/database.cxx b/idl/source/prj/database.cxx
index f76b38687915..b63205a0911b 100644
--- a/idl/source/prj/database.cxx
+++ b/idl/source/prj/database.cxx
@@ -221,7 +221,7 @@ bool SvIdlDataBase::ReadIdFile( const OString& rOFileName )
else if( rTok.Is( SvHash_include() ) )
{
rTok = aTokStm.GetToken_Next();
- OStringBuffer aNameBuf;
+ OStringBuffer aNameBuf(128);
if( rTok.IsString() )
aNameBuf.append(rTok.GetString());
else if( rTok.IsChar() && rTok.GetChar() == '<' )
diff --git a/include/xmlreader/pad.hxx b/include/xmlreader/pad.hxx
index 433b2044300a..d450f7a54c96 100644
--- a/include/xmlreader/pad.hxx
+++ b/include/xmlreader/pad.hxx
@@ -49,7 +49,7 @@ private:
SAL_DLLPRIVATE void flushSpan();
Span span_;
- OStringBuffer buffer_;
+ OStringBuffer buffer_ {256};
};
}
diff --git a/sal/Module_sal.mk b/sal/Module_sal.mk
index 4d7a84ee4e61..b7b3732e3db5 100644
--- a/sal/Module_sal.mk
+++ b/sal/Module_sal.mk
@@ -28,7 +28,6 @@ $(eval $(call gb_Module_add_check_targets,sal,\
$(if $(filter WNT,$(OS)),CppunitTest_sal_comtools) \
CppunitTest_sal_osl_security \
CppunitTest_sal_osl \
- CppunitTest_sal_rtl \
CppunitTest_sal_types \
))
diff --git a/sal/osl/unx/file_url.cxx b/sal/osl/unx/file_url.cxx
index d149d31e1252..33fcd2952802 100644
--- a/sal/osl/unx/file_url.cxx
+++ b/sal/osl/unx/file_url.cxx
@@ -171,8 +171,8 @@ bool decodeFromUtf8(std::u16string_view text, OString * result) {
assert(result != nullptr);
auto p = text.data();
auto const end = p + text.size();
- OUStringBuffer ubuf;
- OStringBuffer bbuf;
+ OUStringBuffer ubuf(static_cast<int>(text.size()));
+ OStringBuffer bbuf(PATH_MAX);
while (p < end) {
rtl::uri::detail::EscapeType t;
sal_uInt32 c = rtl::uri::detail::readUcs4(&p, end, true, RTL_TEXTENCODING_UTF8, &t);
@@ -935,15 +935,16 @@ oslFileError osl::detail::convertUrlToPathname(OUString const & url, OString * p
oslFileError osl::detail::convertPathnameToUrl(OString const & pathname, OUString * url) {
assert(url != nullptr);
- OUStringBuffer buf("file:");
+ OUStringBuffer buf(10+pathname.getLength());
+ buf.append("file:");
if (pathname.startsWith("/")) {
buf.append("//");
// so if pathname should ever start with "//" that isn't mistaken for an authority
// component
}
for (sal_Size convert = pathname.getLength();;) {
- OUStringBuffer ubuf;
auto n = std::max(convert, sal_Size(PATH_MAX)); // approximation of required converted size
+ OUStringBuffer ubuf(static_cast<int>(n));
auto s = ubuf.appendUninitialized(n);
sal_uInt32 info;
sal_Size converted;
diff --git a/sal/osl/unx/tempfile.cxx b/sal/osl/unx/tempfile.cxx
index cc29a6f59625..84f44cbd4b32 100644
--- a/sal/osl/unx/tempfile.cxx
+++ b/sal/osl/unx/tempfile.cxx
@@ -193,15 +193,17 @@ static oslFileError osl_create_temp_file_impl_(
len_base_dir = rtl_uString_getLength(pustr_base_directory);
- rtl_uStringbuffer_newFromStr_WithLength(
+ rtl_uString_new_WithLength(
&tmp_file_path,
- rtl_uString_getStr(const_cast<rtl_uString*>(pustr_base_directory)),
- len_base_dir);
+ (len_base_dir + 1 + RAND_NAME_LENGTH));
+ capacity = len_base_dir + 1 + RAND_NAME_LENGTH;
- rtl_uStringbuffer_ensureCapacity(
+ rtl_uStringbuffer_insert(
&tmp_file_path,
&capacity,
- (len_base_dir + 1 + RAND_NAME_LENGTH));
+ 0,
+ rtl_uString_getStr(const_cast<rtl_uString*>(pustr_base_directory)),
+ len_base_dir);
offset_file_name = len_base_dir;
diff --git a/sal/rtl/bootstrap.cxx b/sal/rtl/bootstrap.cxx
index 4417246e9eea..7f5d4317636a 100644
--- a/sal/rtl/bootstrap.cxx
+++ b/sal/rtl/bootstrap.cxx
@@ -800,7 +800,7 @@ void SAL_CALL rtl_bootstrap_expandMacros(rtl_uString ** macro)
void rtl_bootstrap_encode(rtl_uString const * value, rtl_uString ** encoded)
{
OSL_ASSERT(value);
- OUStringBuffer b;
+ OUStringBuffer b(value->length+5);
for (sal_Int32 i = 0; i < value->length; ++i)
{
sal_Unicode c = value->buffer[i];
@@ -868,7 +868,7 @@ OUString expandMacros(
ExpandRequestLink const * requestStack)
{
SAL_INFO("sal.bootstrap", "expandMacros called with: " << text);
- OUStringBuffer buf;
+ OUStringBuffer buf(2048);
for (sal_Int32 i = 0; i < text.getLength();)
{
@@ -975,7 +975,7 @@ OUString expandMacros(
}
else
{
- OUStringBuffer kbuf;
+ OUStringBuffer kbuf(text.getLength());
for (; i < text.getLength();)
{
sal_Int32 j = i;
diff --git a/sal/rtl/uri.cxx b/sal/rtl/uri.cxx
index ae88e18b8774..592b92c88525 100644
--- a/sal/rtl/uri.cxx
+++ b/sal/rtl/uri.cxx
@@ -638,7 +638,7 @@ void SAL_CALL rtl_uriEncode(rtl_uString * pText, sal_Bool const * pCharClass,
sal_Unicode const * p = pText->buffer;
sal_Unicode const * pEnd = p + pText->length;
- sal_Int32 nCapacity = pText->length;
+ sal_Int32 nCapacity = 256;
rtl_uString_new_WithLength(pResult, nCapacity);
while (p < pEnd)
@@ -758,9 +758,9 @@ sal_Bool SAL_CALL rtl_uriConvertRelToAbs(rtl_uString * pBaseUriRef,
{
// Use the strict parser algorithm from RFC 3986, section 5.2, to turn the
// relative URI into an absolute one:
- OUStringBuffer aBuffer;
Components aRelComponents;
parseUriRef(pRelUriRef, &aRelComponents);
+ OUStringBuffer aBuffer(256);
if (aRelComponents.aScheme.isPresent())
{
diff --git a/stoc/source/inspect/introspection.cxx b/stoc/source/inspect/introspection.cxx
index b5cebfd268d5..58434b2f51ea 100644
--- a/stoc/source/inspect/introspection.cxx
+++ b/stoc/source/inspect/introspection.cxx
@@ -1438,7 +1438,7 @@ struct TypeKey {
// the chance of matches between different implementations' getTypes(),
// but the old scheme of using getImplementationId() would have missed
// those matches, too:
- OUStringBuffer b;
+ OUStringBuffer b(static_cast<int>(theTypes.size() * 64));
for (const css::uno::Type& rType : theTypes) {
b.append(rType.getTypeName());
b.append('*'); // arbitrary delimiter not used by type grammar
diff --git a/stoc/source/uriproc/ExternalUriReferenceTranslator.cxx b/stoc/source/uriproc/ExternalUriReferenceTranslator.cxx
index f7b99bf9a8e7..9e21c5aef79f 100644
--- a/stoc/source/uriproc/ExternalUriReferenceTranslator.cxx
+++ b/stoc/source/uriproc/ExternalUriReferenceTranslator.cxx
@@ -92,7 +92,7 @@ OUString Translator::translateToInternal(
return externalUriReference;
}
sal_Int32 i = RTL_CONSTASCII_LENGTH("file:");
- OUStringBuffer buf;
+ OUStringBuffer buf(128);
buf.append(std::u16string_view(externalUriReference).substr(0, i));
// Some environments (e.g., Java) produce illegal file URLs without an
// authority part; treat them as having an empty authority part:
@@ -140,7 +140,7 @@ OUString Translator::translateToExternal(
return internalUriReference;
}
sal_Int32 i = RTL_CONSTASCII_LENGTH("file://");
- OUStringBuffer buf;
+ OUStringBuffer buf(128);
buf.append(std::u16string_view(internalUriReference).substr(0, i));
rtl_TextEncoding encoding = osl_getThreadTextEncoding();
for (bool path = true;;) {
diff --git a/stoc/source/uriproc/UriReference.cxx b/stoc/source/uriproc/UriReference.cxx
index dd4d68d3144e..75ed1abaa2a4 100644
--- a/stoc/source/uriproc/UriReference.cxx
+++ b/stoc/source/uriproc/UriReference.cxx
@@ -51,7 +51,7 @@ UriReference::~UriReference() {}
OUString UriReference::getUriReference()
{
osl::MutexGuard g(m_mutex);
- OUStringBuffer buf;
+ OUStringBuffer buf(128);
if (!m_scheme.isEmpty()) {
buf.append(m_scheme);
buf.append(':');
diff --git a/stoc/source/uriproc/UriReferenceFactory.cxx b/stoc/source/uriproc/UriReferenceFactory.cxx
index 3a5f30b850de..bb96a55d88ed 100644
--- a/stoc/source/uriproc/UriReferenceFactory.cxx
+++ b/stoc/source/uriproc/UriReferenceFactory.cxx
@@ -356,7 +356,7 @@ css::uno::Reference< css::uri::XUriReference > Factory::parse(
if (n >= 0) {
scheme = uriReference.copy(0, n);
schemeSpecificPart = uriReference.copy(n + 1, fragment - (n + 1));
- OUStringBuffer buf;
+ OUStringBuffer buf(128);
buf.append("com.sun.star.uri.UriSchemeParser_");
for (sal_Int32 i = 0; i < scheme.getLength(); ++i) {
sal_Unicode c = scheme[i];
@@ -488,7 +488,8 @@ css::uno::Reference< css::uri::XUriReference > Factory::makeAbsolute(
}
return parse(abs.makeStringAndClear());
} else {
- OUStringBuffer abs(baseUriReference->getScheme());
+ OUStringBuffer abs(128);
+ abs.append(baseUriReference->getScheme());
abs.append(':');
if (uriReference->hasAuthority()) {
abs.append("//");
@@ -597,7 +598,7 @@ css::uno::Reference< css::uri::XUriReference > Factory::makeRelative(
uriReference->getScheme())) {
return clone(uriReference);
} else {
- OUStringBuffer rel;
+ OUStringBuffer rel(128);
bool omitQuery = false;
if ((baseUriReference->hasAuthority() != uriReference->hasAuthority())
|| !equalIgnoreEscapeCase(
diff --git a/stoc/source/uriproc/UriSchemeParser_vndDOTsunDOTstarDOTscript.cxx b/stoc/source/uriproc/UriSchemeParser_vndDOTsunDOTstarDOTscript.cxx
index 1191a711262f..b63fad9d529e 100644
--- a/stoc/source/uriproc/UriSchemeParser_vndDOTsunDOTstarDOTscript.cxx
+++ b/stoc/source/uriproc/UriSchemeParser_vndDOTsunDOTstarDOTscript.cxx
@@ -282,10 +282,9 @@ void SAL_CALL UrlReference::setName(OUString const & name)
sal_Int32 i = 0;
parsePart(m_base.m_path, true, &i);
- OUStringBuffer newPath;
- newPath.append(encodeNameOrParamFragment(name));
- newPath.append(std::u16string_view(m_base.m_path).substr(i));
- m_base.m_path = newPath.makeStringAndClear();
+ auto tmp = std::u16string_view(m_base.m_path).substr(i);
+ m_base.m_path = encodeNameOrParamFragment(name) +
+ rtl::OUStringView(tmp.data(), tmp.length());
}
sal_Bool UrlReference::hasParameter(OUString const & key)
@@ -314,7 +313,7 @@ void UrlReference::setParameter(OUString const & key, OUString const & value)
i = m_base.m_path.getLength();
}
- OUStringBuffer newPath;
+ OUStringBuffer newPath(128);
newPath.append(std::u16string_view(m_base.m_path).substr(0, i));
if (!bExistent) {
newPath.append( m_base.m_path.indexOf('?') < 0 ? '?' : '&' );
diff --git a/stoc/source/uriproc/VndSunStarPkgUrlReferenceFactory.cxx b/stoc/source/uriproc/VndSunStarPkgUrlReferenceFactory.cxx
index ff8aa8e84a8e..b6e926bd2e7c 100644
--- a/stoc/source/uriproc/VndSunStarPkgUrlReferenceFactory.cxx
+++ b/stoc/source/uriproc/VndSunStarPkgUrlReferenceFactory.cxx
@@ -94,7 +94,7 @@ Factory::createVndSunStarPkgUrlReference(
" XVndSunStarPkgUrlReferenceFactory.createVndSunStarPkgUrlReference");
}
if (authority->isAbsolute() && !authority->hasFragment()) {
- OUStringBuffer buf;
+ OUStringBuffer buf(128);
buf.append("vnd.sun.star.pkg://");
buf.append(
rtl::Uri::encode(
diff --git a/stoc/test/uriproc/test_uriproc.cxx b/stoc/test/uriproc/test_uriproc.cxx
index 3cb36343ce32..14132fa70031 100644
--- a/stoc/test/uriproc/test_uriproc.cxx
+++ b/stoc/test/uriproc/test_uriproc.cxx
@@ -82,7 +82,7 @@ OString createTestAssertEqualMessage(
char const * expectedExpr, char const * actualExpr, T3 const & expected,
T4 const & actual)
{
- OUStringBuffer buf;
+ OUStringBuffer buf(512);
buf.appendAscii(token1);
buf.append('|');
append(buf, token2);
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 9a0660f74e24..04e32464d8b2 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -2719,28 +2719,27 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, bool bNoAdditio
const NfKeywordTable & rKeyword = pFormatScanner->GetKeywords();
i18n::NumberFormatCode aSingleFormatCode;
- OUStringBuffer aBuf;
aSingleFormatCode.Usage = i18n::KNumberFormatUsage::DATE_TIME;
// YYYY-MM-DD HH:MM:SS ISO (with blank instead of 'T')
- aBuf.append( rKeyword[NF_KEY_YYYY]).append('-').
- append( rKeyword[NF_KEY_MM]).append('-').
- append( rKeyword[NF_KEY_DD]).append(' ').
- append( rKeyword[NF_KEY_HH]).append(':').
- append( rKeyword[NF_KEY_MMI]).append(':').
- append( rKeyword[NF_KEY_SS]);
- aSingleFormatCode.Code = aBuf.makeStringAndClear();
+ aSingleFormatCode.Code =
+ rKeyword[NF_KEY_YYYY] + "-" +
+ rKeyword[NF_KEY_MM] + "-" +
+ rKeyword[NF_KEY_DD] + " " +
+ rKeyword[NF_KEY_HH] + ":" +
+ rKeyword[NF_KEY_MMI] + ":" +
+ rKeyword[NF_KEY_SS];
ImpInsertFormat( aSingleFormatCode,
CLOffset + ZF_STANDARD_DATETIME+2 /* NF_DATETIME_ISO_YYYYMMDD_HHMMSS */ );
// YYYY-MM-DD"T"HH:MM:SS ISO
- aBuf.append( rKeyword[NF_KEY_YYYY]).append('-').
- append( rKeyword[NF_KEY_MM]).append('-').
- append( rKeyword[NF_KEY_DD]).append("\"T\"").
- append( rKeyword[NF_KEY_HH]).append(':').
- append( rKeyword[NF_KEY_MMI]).append(':').
- append( rKeyword[NF_KEY_SS]);
- aSingleFormatCode.Code = aBuf.makeStringAndClear();
+ aSingleFormatCode.Code =
+ rKeyword[NF_KEY_YYYY] + "-" +
+ rKeyword[NF_KEY_MM] + "-" +
+ rKeyword[NF_KEY_DD] + "\"T\"" +
+ rKeyword[NF_KEY_HH] + ":" +
+ rKeyword[NF_KEY_MMI] + ":" +
+ rKeyword[NF_KEY_SS];
SvNumberformat* pFormat = ImpInsertFormat( aSingleFormatCode,
CLOffset + ZF_STANDARD_DATETIME+3 /* NF_DATETIME_ISO_YYYYMMDDTHHMMSS */ );
assert(pFormat);
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 63a8b5d9e3ab..41db17082089 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -1647,7 +1647,7 @@ short SvNumberformat::ImpNextSymbol(OUStringBuffer& rString,
sal_Unicode cLetter = ' '; // Preliminary result
sal_Int32 nLen = rString.getLength();
ScanState eState = SsStart;
- OUStringBuffer sBuffSymbol;
+ OUStringBuffer sBuffSymbol(32);
const NfKeywordTable & rKeywords = rScan.GetKeywords();
while (nPos < nLen && eState != SsStop)
@@ -1975,7 +1975,7 @@ bool SvNumberformat::GetNewCurrencySymbol( OUString& rSymbol,
// static
OUString SvNumberformat::StripNewCurrencyDelimiters( const OUString& rStr )
{
- OUStringBuffer aTmp;
+ OUStringBuffer aTmp(rStr.getLength());
sal_Int32 nStartPos, nPos, nLen;
nLen = rStr.getLength();
nStartPos = 0;
diff --git a/svx/source/gengal/gengal.cxx b/svx/source/gengal/gengal.cxx
index 90304bea0d14..99e7f4820860 100644
--- a/svx/source/gengal/gengal.cxx
+++ b/svx/source/gengal/gengal.cxx
@@ -200,7 +200,7 @@ static std::vector<OUString> ReadResponseFile_Impl(OUString const& rInput)
}
std::vector<OUString> ret;
- OUStringBuffer b;
+ OUStringBuffer b(256);
char buf[1<<16];
while (true)
{
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 91fe51a9e283..39992a1834ca 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -231,9 +231,12 @@ inline sal_Int32 INetURLObject::SubString::clear()
inline sal_Int32 INetURLObject::SubString::set(OUStringBuffer & rString,
OUString const & rSubString)
{
- OUString sTemp(rString.makeStringAndClear());
- sal_Int32 nDelta = set(sTemp, rSubString);
- rString.append(sTemp);
+ sal_Int32 nDelta = rSubString.getLength() - m_nLength;
+
+ rString.remove(m_nBegin, m_nLength);
+ rString.insert(m_nBegin, rSubString);
+
+ m_nLength = rSubString.getLength();
return nDelta;
}
@@ -698,7 +701,7 @@ bool INetURLObject::setAbsURIRef(OUString const & rTheAbsURIRef,
sal_uInt32 nFragmentDelimiter = '#';
- OUStringBuffer aSynAbsURIRef;
+ OUStringBuffer aSynAbsURIRef(rTheAbsURIRef.getLength()*2);
// Parse <scheme>:
sal_Unicode const * p = pPos;
@@ -949,7 +952,7 @@ bool INetURLObject::setAbsURIRef(OUString const & rTheAbsURIRef,
return false;
}
aSynAbsURIRef.append("//");
- OUStringBuffer aSynUser;
+ OUStringBuffer aSynUser(128);
bool bHasUser = false;
while (pPos < pEnd && *pPos != '@'
@@ -966,7 +969,7 @@ bool INetURLObject::setAbsURIRef(OUString const & rTheAbsURIRef,
bHasUser = *pPos == '@';
}
- OUStringBuffer aSynAuthority;
+ OUStringBuffer aSynAuthority(64);
if ( !bHasUser )
{
aSynAuthority = aSynUser;
@@ -2875,7 +2878,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme,
DBG_ASSERT(pBegin, "INetURLObject::parsePath(): Null output param");
sal_Unicode const * pPos = *pBegin;
- OUStringBuffer aTheSynPath;
+ OUStringBuffer aTheSynPath(256);
switch (eScheme)
{
@@ -3267,7 +3270,7 @@ bool INetURLObject::insertName(OUString const & rTheName,
}
}
- OUStringBuffer aNewPath;
+ OUStringBuffer aNewPath(256);
aNewPath.append(pPathBegin, pPrefixEnd - pPathBegin);
aNewPath.append('/');
aNewPath.append(encodeText(rTheName, PART_PCHAR,
@@ -3392,7 +3395,7 @@ OUString INetURLObject::decode(sal_Unicode const * pBegin,
default:
break;
}
- OUStringBuffer aResult;
+ OUStringBuffer aResult(static_cast<int>(pEnd-pBegin));
while (pBegin < pEnd)
{
EscapeType eEscapeType;
@@ -3960,7 +3963,7 @@ bool INetURLObject::removeSegment(sal_Int32 nIndex, bool bIgnoreFinalSlash)
if (!aSegment.isPresent())
return false;
- OUStringBuffer aNewPath;
+ OUStringBuffer aNewPath(m_aPath.getLength());
aNewPath.append(m_aAbsURIRef.getStr() + m_aPath.getBegin(),
aSegment.getBegin() - m_aPath.getBegin());
if (bIgnoreFinalSlash && aSegment.getEnd() == m_aPath.getEnd())
@@ -4159,7 +4162,7 @@ bool INetURLObject::setExtension(OUString const & rTheExtension,
if (!pExtension)
pExtension = p;
- OUStringBuffer aNewPath;
+ OUStringBuffer aNewPath(128);
aNewPath.append(pPathBegin, pExtension - pPathBegin);
aNewPath.append('.');
aNewPath.append(encodeText(rTheExtension, PART_PCHAR,
diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx
index f1c9080996dd..f974c911013c 100644
--- a/tools/source/inet/inetmime.cxx
+++ b/tools/source/inet/inetmime.cxx
@@ -373,7 +373,7 @@ bool parseParameters(ParameterList const & rInput,
= getCharsetEncoding(it->m_aCharset.getStr(),
it->m_aCharset.getStr()
+ it->m_aCharset.getLength());
- OUStringBuffer aValue;
+ OUStringBuffer aValue(64);
bool bBadEncoding = false;
itNext = it;
do
@@ -715,7 +715,7 @@ sal_Unicode const * scanParameters(sal_Unicode const * pBegin,
else if (p != pEnd && *p == '"')
if (pParameters)
{
- OStringBuffer aSink;
+ OStringBuffer aSink(256);
bool bInvalid = false;
for (++p;;)
{
diff --git a/tools/source/misc/extendapplicationenvironment.cxx b/tools/source/misc/extendapplicationenvironment.cxx
index 64e1d9801a79..0324a7d0d380 100644
--- a/tools/source/misc/extendapplicationenvironment.cxx
+++ b/tools/source/misc/extendapplicationenvironment.cxx
@@ -47,7 +47,7 @@ void extendApplicationEnvironment() {
#endif
// Make sure URE_BOOTSTRAP environment variable is set (failure is fatal):
- OUStringBuffer env;
+ OUStringBuffer env(512);
OUString envVar("URE_BOOTSTRAP");
OUString uri;
if (rtl::Bootstrap::get(envVar, uri))
diff --git a/ucb/source/core/ucb.cxx b/ucb/source/core/ucb.cxx
index 991ea410149d..062db439784b 100644
--- a/ucb/source/core/ucb.cxx
+++ b/ucb/source/core/ucb.cxx
@@ -786,7 +786,7 @@ bool UniversalContentBroker::getContentProviderData(
uno::Reference< lang::XMultiServiceFactory > xConfigProv =
configuration::theDefaultProvider::get( m_xContext );
- OUStringBuffer aFullPath;
+ OUStringBuffer aFullPath(128);
aFullPath.append(
"/org.openoffice.ucb.Configuration/ContentProviders"
"/['" );
diff --git a/ucb/source/ucp/inc/urihelper.hxx b/ucb/source/ucp/inc/urihelper.hxx
index 146708c6ee48..19d459181b2f 100644
--- a/ucb/source/ucp/inc/urihelper.hxx
+++ b/ucb/source/ucp/inc/urihelper.hxx
@@ -80,7 +80,7 @@ namespace ucb_impl { namespace urihelper {
rtl_UriEncodeKeepEscapes, /* #i81690# */
RTL_TEXTENCODING_UTF8 );
- OUStringBuffer aResult;
+ OUStringBuffer aResult(256);
sal_Int32 nIndex = 0;
do
{
diff --git a/ucb/source/ucp/webdav-neon/NeonUri.cxx b/ucb/source/ucp/webdav-neon/NeonUri.cxx
index 17db426dcf5b..f7e94b38ddca 100644
--- a/ucb/source/ucp/webdav-neon/NeonUri.cxx
+++ b/ucb/source/ucp/webdav-neon/NeonUri.cxx
@@ -149,7 +149,8 @@ void NeonUri::init( const OString & rUri, const ne_uri * pUri )
void NeonUri::calculateURI ()
{
- OUStringBuffer aBuf( mScheme );
+ OUStringBuffer aBuf( 256 );
+ aBuf.append( mScheme );
aBuf.append( "://" );
if ( !mUserInfo.isEmpty() )
{
diff --git a/unoidl/source/sourceprovider-parser.y b/unoidl/source/sourceprovider-parser.y
index 5fb347099ced..d7111d0e3cfa 100644
--- a/unoidl/source/sourceprovider-parser.y
+++ b/unoidl/source/sourceprovider-parser.y
@@ -4028,7 +4028,8 @@ OUString SourceProviderType::getName() const {
return name;
case unoidl::detail::SourceProviderType::TYPE_INSTANTIATED_POLYMORPHIC_STRUCT:
{
- OUStringBuffer n(name + "<");
+ OUStringBuffer n(512);
+ n.append(name + "<");
for (auto i(subtypes.begin()); i != subtypes.end(); ++i) {
if (i != subtypes.begin()) {
n.append(",");
diff --git a/unotools/source/config/pathoptions.cxx b/unotools/source/config/pathoptions.cxx
index 4219c8c44033..b6e5006ce39c 100644
--- a/unotools/source/config/pathoptions.cxx
+++ b/unotools/source/config/pathoptions.cxx
@@ -236,7 +236,7 @@ const OUString& SvtPathOptions_Impl::GetPath( SvtPathOptions::Paths ePath )
ePath == SvtPathOptions::PATH_ICONSET)
{
auto ctx = comphelper::getProcessComponentContext();
- OUStringBuffer buf;
+ OUStringBuffer buf(aPathValue.getLength()*2);
for (sal_Int32 i = 0;;)
{
buf.append(
diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx
index c6ecb2109a74..62ceb456c8a6 100644
--- a/vcl/source/window/syswin.cxx
+++ b/vcl/source/window/syswin.cxx
@@ -548,7 +548,7 @@ OString ImplWindowStateToStr(const WindowStateData& rData)
if ( nValidMask == WindowStateMask::NONE )
return OString();
- OStringBuffer rStrBuf;
+ OStringBuffer rStrBuf(64);
if ( nValidMask & WindowStateMask::X )
rStrBuf.append(static_cast<sal_Int32>(rData.GetX()));
diff --git a/xmloff/source/draw/xexptran.cxx b/xmloff/source/draw/xexptran.cxx
index c85022b20ae0..f0a297c935f3 100644
--- a/xmloff/source/draw/xexptran.cxx
+++ b/xmloff/source/draw/xexptran.cxx
@@ -77,7 +77,7 @@ static double Imp_GetDoubleChar(const OUString& rStr, sal_Int32& rPos, const sal
const SvXMLUnitConverter& rConv, double fRetval, bool bLookForUnits = false)
{
sal_Unicode aChar(rStr[rPos]);
- OUStringBuffer sNumberString;
+ OUStringBuffer sNumberString(32);
if('+' == aChar || '-' == aChar)
{