summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-03-24 00:27:51 +0100
committerAndras Timar <andras.timar@collabora.com>2016-06-26 14:00:42 +0200
commit626cf74c45aa3b33257de472cde37c825217db28 (patch)
tree3d49a042fb5357091152c71b9ea5e4860c666676 /unotools
parente463e73906abd5f1f1447e8b9fb8e7037caa1644 (diff)
don't allocate and destroy a LocaleDataItem for each cell, tdf#97989
Change-Id: I8bcdc7a42c87d17fde1dc9c79bc361bb625f992b Reviewed-on: https://gerrit.libreoffice.org/23480 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> (cherry picked from commit 7da3a53958695bfb1405fa513f71beddc6c0ecb7)
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/i18n/localedatawrapper.cxx36
1 files changed, 33 insertions, 3 deletions
diff --git a/unotools/source/i18n/localedatawrapper.cxx b/unotools/source/i18n/localedatawrapper.cxx
index f52065540ee5..9ca5c0c15281 100644
--- a/unotools/source/i18n/localedatawrapper.cxx
+++ b/unotools/source/i18n/localedatawrapper.cxx
@@ -63,6 +63,21 @@ namespace
{};
}
+bool LocaleDataWrapper::Locale_Compare::operator()(const css::lang::Locale& rLocale1, const css::lang::Locale& rLocale2) const
+{
+ if (rLocale1.Language < rLocale2.Language)
+ return true;
+ else if (rLocale1.Language > rLocale2.Language)
+ return false;
+
+ if (rLocale1.Country < rLocale2.Country)
+ return true;
+ else if (rLocale1.Country > rLocale2.Country)
+ return false;
+
+ return rLocale1.Variant < rLocale2.Variant;
+}
+
sal_uInt8 LocaleDataWrapper::nLocaleDataChecking = 0;
LocaleDataWrapper::LocaleDataWrapper(
@@ -157,17 +172,32 @@ css::i18n::LanguageCountryInfo LocaleDataWrapper::getLanguageCountryInfo() const
return css::i18n::LanguageCountryInfo();
}
-css::i18n::LocaleDataItem LocaleDataWrapper::getLocaleItem() const
+const css::i18n::LocaleDataItem& LocaleDataWrapper::getLocaleItem() const
{
+ {
+ ::utl::ReadWriteGuard aGuard( aMutex );
+ const css::lang::Locale& rLocal = getMyLocale();
+ auto itr = maDataItemCache.find(rLocal);
+ if (itr != maDataItemCache.end())
+ return itr->second;
+ }
+
try
{
- return xLD->getLocaleItem( getMyLocale() );
+ ::utl::ReadWriteGuard aGuard( aMutex );
+
+ const css::lang::Locale& rLocal = getMyLocale();
+ css::i18n::LocaleDataItem aItem = xLD->getLocaleItem( rLocal );
+ auto aRet = maDataItemCache.insert(std::make_pair(rLocal, aItem));
+ assert(aRet.second);
+ return aRet.first->second;
}
catch (const Exception& e)
{
SAL_WARN( "unotools.i18n", "getLocaleItem: Exception caught " << e.Message );
}
- return css::i18n::LocaleDataItem();
+ static css::i18n::LocaleDataItem aEmptyItem;
+ return aEmptyItem;
}
css::uno::Sequence< css::i18n::Currency2 > LocaleDataWrapper::getAllCurrencies() const