diff options
author | Eike Rathke <erack@redhat.com> | 2013-03-28 16:12:17 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-03-29 14:09:00 +0100 |
commit | 80bbe6d1ca9605a94fd028845bda1242cc13a9ba (patch) | |
tree | 5a2b7f9932465590adb145a25305f30c139f91f4 /i18npool | |
parent | e5114027382a092e91b5280a54db256bf0b5c556 (diff) |
slightly optimized operator==() and equals()
Change-Id: I05bacddf8cf61adbbcaed03c83ae42b06e76160a
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/source/languagetag/languagetag.cxx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/i18npool/source/languagetag/languagetag.cxx b/i18npool/source/languagetag/languagetag.cxx index 99b12cfe63a3..16b81d8427dc 100644 --- a/i18npool/source/languagetag/languagetag.cxx +++ b/i18npool/source/languagetag/languagetag.cxx @@ -1120,6 +1120,11 @@ LanguageTag & LanguageTag::makeFallback() bool LanguageTag::equals( const LanguageTag & rLanguageTag, bool bResolveSystem ) const { + // If SYSTEM is not to be resolved or either both are SYSTEM or none, we + // can use the operator==() optimization. + if (!bResolveSystem || isSystemLocale() == rLanguageTag.isSystemLocale()) + return operator==( rLanguageTag); + // Compare full language tag strings. return getBcp47( bResolveSystem) == rLanguageTag.getBcp47( bResolveSystem); } @@ -1127,6 +1132,16 @@ bool LanguageTag::equals( const LanguageTag & rLanguageTag, bool bResolveSystem bool LanguageTag::operator==( const LanguageTag & rLanguageTag ) const { + if (isSystemLocale() && rLanguageTag.isSystemLocale()) + return true; // both SYSTEM + + // No need to convert to BCP47 if both Lang-IDs are available. + if (mbInitializedLangID && rLanguageTag.mbInitializedLangID) + { + // Equal if same ID and no SYSTEM is involved or both are SYSTEM. + return mnLangID == rLanguageTag.mnLangID && isSystemLocale() == rLanguageTag.isSystemLocale(); + } + // Compare full language tag strings but SYSTEM unresolved. return getBcp47( false) == rLanguageTag.getBcp47( false); } |