diff options
author | Eike Rathke <erack@redhat.com> | 2021-08-15 01:44:54 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2021-08-15 02:57:21 +0200 |
commit | 6c4ff1d23ef61e708f3450d1b0ae77cc78cac731 (patch) | |
tree | 5a52337fa072c5c96cc98655f871c82a4160c3d0 /configmgr | |
parent | 23f17b7ea6fbd2f422c7e40192ae60e4df25224c (diff) |
Avoid computing LanguageTag fallbacks several hundred times
... over and over again even for known and present locales for
each and every localizable config item.
Change-Id: I19974c56169f45a7c53ed6b0eede47365e1365dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120496
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
Diffstat (limited to 'configmgr')
-rw-r--r-- | configmgr/source/access.cxx | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx index 02e3f557c684..28ef91000fb1 100644 --- a/configmgr/source/access.cxx +++ b/configmgr/source/access.cxx @@ -1385,8 +1385,14 @@ rtl::Reference< ChildAccess > Access::getChild(OUString const & name) { locale = comphelper::LibreOfficeKit::getLanguageTag().getBcp47(); if (!locale.isEmpty()) { - // Find the best match using the LanguageTag fallback mechanism - std::vector<OUString> aFallbacks = LanguageTag(locale).getFallbackStrings(true); + // Try exact match first, avoiding all fallback overhead. + rtl::Reference<ChildAccess> directChild(getChild(locale)); + if (directChild.is()) + return directChild; + + // Find the best match using the LanguageTag fallback mechanism, + // excluding the original tag. + std::vector<OUString> aFallbacks = LanguageTag(locale).getFallbackStrings(false); for (const OUString& rFallback : aFallbacks) { rtl::Reference<ChildAccess> child(getChild(rFallback)); @@ -1398,8 +1404,8 @@ rtl::Reference< ChildAccess > Access::getChild(OUString const & name) { // xml:lang attributes, look for the first entry with the same first // segment as the requested language tag before falling back to // defaults (see fdo#33638): - assert(aFallbacks.size() > 0); - locale = aFallbacks[aFallbacks.size() - 1]; + if (aFallbacks.size() > 0) + locale = aFallbacks[aFallbacks.size() - 1]; assert( !locale.isEmpty() && locale.indexOf('-') == -1 && locale.indexOf('_') == -1); |