summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-12-18 20:38:04 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-12-20 11:00:27 +0100
commit24ea26f55ee4e8a3c69b6dc9911a8c42e56f1eb2 (patch)
treed797f881fee47d8300d3f9e8c3f9c83582c6f22e /i18npool
parent38768976f82834010f160cc234eade5ca5aeefa5 (diff)
pass by ref in lcl_LookupTableStatic
rather than passing by pointer and then asserting that the pointer is not null Change-Id: I8df464ca2ae770ab343417fe1b15c378c88110d2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127111 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/source/localedata/localedata.cxx44
1 files changed, 16 insertions, 28 deletions
diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx
index 6b02040efc0a..666858fcb3cf 100644
--- a/i18npool/source/localedata/localedata.cxx
+++ b/i18npool/source/localedata/localedata.cxx
@@ -488,7 +488,7 @@ public:
oslGenericFunction getFunctionSymbolByName(
const OUString& localeName, const char* pFunction,
- std::unique_ptr<LocaleDataLookupTableItem>* pOutCachedItem );
+ std::unique_ptr<LocaleDataLookupTableItem>& rOutCachedItem );
private:
::osl::Mutex maMutex;
@@ -519,7 +519,7 @@ lcl_LookupTableHelper::~lcl_LookupTableHelper()
oslGenericFunction lcl_LookupTableHelper::getFunctionSymbolByName(
const OUString& localeName, const char* pFunction,
- std::unique_ptr<LocaleDataLookupTableItem>* pOutCachedItem )
+ std::unique_ptr<LocaleDataLookupTableItem>& rOutCachedItem )
{
OUString aFallback;
bool bFallback = (localeName.indexOf( cUnder) < 0);
@@ -546,18 +546,12 @@ oslGenericFunction lcl_LookupTableHelper::getFunctionSymbolByName(
{
if (rCurrent.dllName == i.pLib)
{
- OSL_ASSERT( pOutCachedItem );
- if( pOutCachedItem )
- {
- (*pOutCachedItem).reset(new LocaleDataLookupTableItem( rCurrent ));
- (*pOutCachedItem)->localeName = i.pLocale;
- OString sSymbolName = OString::Concat(pFunction) + "_" +
- (*pOutCachedItem)->localeName;
- return (*pOutCachedItem)->module->getFunctionSymbol(
- sSymbolName.getStr());
- }
- else
- return nullptr;
+ rOutCachedItem.reset(new LocaleDataLookupTableItem( rCurrent ));
+ rOutCachedItem->localeName = i.pLocale;
+ OString sSymbolName = OString::Concat(pFunction) + "_" +
+ rOutCachedItem->localeName;
+ return rOutCachedItem->module->getFunctionSymbol(
+ sSymbolName.getStr());
}
}
}
@@ -575,20 +569,14 @@ oslGenericFunction lcl_LookupTableHelper::getFunctionSymbolByName(
::osl::MutexGuard aGuard( maMutex );
auto pTmpModule = module.get();
maLookupTable.emplace_back(i.pLib, module.release(), i.pLocale);
- OSL_ASSERT( pOutCachedItem );
- if( pOutCachedItem )
- {
- pOutCachedItem->reset(new LocaleDataLookupTableItem( maLookupTable.back() ));
- OString sSymbolName = OString::Concat(pFunction) + "_" + (*pOutCachedItem)->localeName;
- return pTmpModule->getFunctionSymbol(sSymbolName.getStr());
- }
- else
- return nullptr;
+ rOutCachedItem.reset(new LocaleDataLookupTableItem( maLookupTable.back() ));
+ OString sSymbolName = OString::Concat(pFunction) + "_" + rOutCachedItem->localeName;
+ return pTmpModule->getFunctionSymbol(sSymbolName.getStr());
}
else
module.reset();
#else
- (void) pOutCachedItem;
+ (void) rOutCachedItem;
if( strcmp(pFunction, "getAllCalendars") == 0 )
return i.getAllCalendars;
@@ -1452,13 +1440,13 @@ oslGenericFunction LocaleDataImpl::getFunctionSymbol( const Locale& rLocale, con
// Load function with name <func>_<lang>_<country> or <func>_<bcp47> and
// fallbacks.
pSymbol = rLookupTable.getFunctionSymbolByName( LocaleDataImpl::getFirstLocaleServiceName( rLocale),
- pFunction, &pCachedItem);
+ pFunction, pCachedItem);
if (!pSymbol)
{
::std::vector< OUString > aFallbacks( LocaleDataImpl::getFallbackLocaleServiceNames( rLocale));
for (const auto& rFallback : aFallbacks)
{
- pSymbol = rLookupTable.getFunctionSymbolByName(rFallback, pFunction, &pCachedItem);
+ pSymbol = rLookupTable.getFunctionSymbolByName(rFallback, pFunction, pCachedItem);
if (pSymbol)
break;
}
@@ -1466,7 +1454,7 @@ oslGenericFunction LocaleDataImpl::getFunctionSymbol( const Locale& rLocale, con
if (!pSymbol)
{
// load default function with name <func>_en_US
- pSymbol = rLookupTable.getFunctionSymbolByName("en_US", pFunction, &pCachedItem);
+ pSymbol = rLookupTable.getFunctionSymbolByName("en_US", pFunction, pCachedItem);
}
if (!pSymbol)
@@ -1494,7 +1482,7 @@ LocaleDataImpl::getAllInstalledLocaleNames()
// Check if the locale is really available and not just in the table,
// don't allow fall backs.
std::unique_ptr<LocaleDataLookupTableItem> pCachedItem;
- if (lcl_LookupTableStatic().getFunctionSymbolByName( name, "getLocaleItem", &pCachedItem )) {
+ if (lcl_LookupTableStatic().getFunctionSymbolByName( name, "getLocaleItem", pCachedItem )) {
if( pCachedItem )
cachedItem = std::move( pCachedItem );
seqRange[nInstalled++] = LanguageTag::convertToLocale( name.replace( cUnder, cHyphen), false);