From 48101a1a0d574db3db1f99c782bd67e885b232bb Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 17 Oct 2019 20:33:50 +0200 Subject: 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 --- oox/source/core/relationshandler.cxx | 10 ++++------ oox/source/ole/olehelper.cxx | 2 +- oox/source/ole/vbamodule.cxx | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) (limited to 'oox') diff --git a/oox/source/core/relationshandler.cxx b/oox/source/core/relationshandler.cxx index 9b7675ff2cb1..fe448bc43a7b 100644 --- a/oox/source/core/relationshandler.cxx +++ b/oox/source/core/relationshandler.cxx @@ -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 diff --git a/oox/source/ole/olehelper.cxx b/oox/source/ole/olehelper.cxx index d2dd4899d2e6..05b787d9f85a 100644 --- a/oox/source/ole/olehelper.cxx +++ b/oox/source/ole/olehelper.cxx @@ -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( '-' ); diff --git a/oox/source/ole/vbamodule.cxx b/oox/source/ole/vbamodule.cxx index b7ff5edb7aec..82a368934794 100644 --- a/oox/source/ole/vbamodule.cxx +++ b/oox/source/ole/vbamodule.cxx @@ -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 ) { -- cgit