summaryrefslogtreecommitdiff
path: root/i18npool
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 /i18npool
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>
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/source/localedata/localedata.cxx29
1 files changed, 13 insertions, 16 deletions
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;