From c68be56c295c8dda3043c80d4641575ec2799e55 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 Change-Id: I385587a922c555c320a45dcc6d644315b72510e9 Reviewed-on: https://gerrit.libreoffice.org/81278 Tested-by: Jenkins Reviewed-by: Noel Grandin --- i18npool/source/breakiterator/xdictionary.cxx | 10 +++++----- i18npool/source/collator/gencoll_rule.cxx | 6 +++++- i18npool/source/indexentry/genindex_data.cxx | 3 ++- 3 files changed, 12 insertions(+), 7 deletions(-) (limited to 'i18npool/source') diff --git a/i18npool/source/breakiterator/xdictionary.cxx b/i18npool/source/breakiterator/xdictionary.cxx index f21e377c68c0..b349066d06d7 100644 --- a/i18npool/source/breakiterator/xdictionary.cxx +++ b/i18npool/source/breakiterator/xdictionary.cxx @@ -165,13 +165,13 @@ void xdictionary::initDictionaryData(const sal_Char *pLang) aEntry.maLang = OString( pLang, strlen( pLang ) ); #ifdef SAL_DLLPREFIX - OUStringBuffer aBuf( sal::static_int_cast(strlen(pLang) + 7 + 6) ); // mostly "lib*.so" (with * == dict_zh) - aBuf.append( SAL_DLLPREFIX ); + OString sModuleName = // mostly "lib*.so" (with * == dict_zh) + SAL_DLLPREFIX #else - OUStringBuffer aBuf( sal::static_int_cast(strlen(pLang) + 7 + 4) ); // mostly "*.dll" (with * == dict_zh) + OString sModuleName = // mostly "*.dll" (with * == dict_zh) #endif - aBuf.append( "dict_" ).appendAscii( pLang ).append( SAL_DLLEXTENSION ); - aEntry.mhModule = osl_loadModuleRelative( &thisModule, aBuf.makeStringAndClear().pData, SAL_LOADMODULE_DEFAULT ); + "dict_" + rtl::OStringView(pLang) + SAL_DLLEXTENSION; + aEntry.mhModule = osl_loadModuleRelativeAscii( &thisModule, sModuleName.getStr(), SAL_LOADMODULE_DEFAULT ); if( aEntry.mhModule ) { oslGenericFunction func; func = osl_getAsciiFunctionSymbol( aEntry.mhModule, "getExistMark" ); diff --git a/i18npool/source/collator/gencoll_rule.cxx b/i18npool/source/collator/gencoll_rule.cxx index fb0349f19b84..33be2a5a2c56 100644 --- a/i18npool/source/collator/gencoll_rule.cxx +++ b/i18npool/source/collator/gencoll_rule.cxx @@ -88,8 +88,12 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) exit(1); } + fseek(fp, 0L, SEEK_END); + int fileSize = ftell(fp); + rewind(fp); + sal_Char str[1024]; - OUStringBuffer Obuf; + OUStringBuffer Obuf(fileSize); while (fgets(str, 1024, fp)) { // don't convert last new line character to Ostr. sal_Int32 len = strlen(str) - 1; diff --git a/i18npool/source/indexentry/genindex_data.cxx b/i18npool/source/indexentry/genindex_data.cxx index d5bad8b18def..128fad664bfb 100644 --- a/i18npool/source/indexentry/genindex_data.cxx +++ b/i18npool/source/indexentry/genindex_data.cxx @@ -49,7 +49,8 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) sal_Int32 address[MAX_ADDRESS]; for (i=0; i