diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2019-10-17 20:33:50 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-10-21 08:36:01 +0200 |
commit | 0f874472c672175135520101837ff0c9d4701d7f (patch) | |
tree | fa6a504bdfc7d5d838caed7cfb87793321797290 /framework | |
parent | 9112c18524c9f5e67d6cbb282586a439e3020cdb (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>
Diffstat (limited to 'framework')
6 files changed, 25 insertions, 27 deletions
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() ) |