diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-07-22 11:11:27 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-07-23 11:22:59 +0200 |
commit | 4e512171c21a193027c35d19a5273507a2725596 (patch) | |
tree | e0c354208a355c22f0e0ba9639b10a1010b2a52f /sal | |
parent | 58ddacdb4be78dd00e05a46459ed0bcbe7531632 (diff) |
no need to allocate these static vars on demand
the constructor can be laid out at compile/link time
Change-Id: I377a537e15199ae81394d76ac662576280a25c25
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119362
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sal')
-rw-r--r-- | sal/rtl/locale.cxx | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/sal/rtl/locale.cxx b/sal/rtl/locale.cxx index bae0f40b3d66..742041ac1579 100644 --- a/sal/rtl/locale.cxx +++ b/sal/rtl/locale.cxx @@ -43,23 +43,17 @@ struct locale_deleter using locale_unique_ptr = std::unique_ptr<rtl_Locale, locale_deleter>; -static std::unordered_map<sal_Int32, locale_unique_ptr>* g_pLocaleTable = nullptr; +static std::unordered_map<sal_Int32, locale_unique_ptr> g_aLocaleTable; static rtl_Locale* g_pDefaultLocale = nullptr; void rtl_locale_init() { - if (!g_pLocaleTable) - g_pLocaleTable = new std::unordered_map<sal_Int32, locale_unique_ptr>; } void rtl_locale_fini() { - if (g_pLocaleTable) - { - delete g_pLocaleTable; - g_pLocaleTable = nullptr; - } + g_aLocaleTable.clear(); g_pDefaultLocale = nullptr; } @@ -81,8 +75,8 @@ rtl_Locale * SAL_CALL rtl_locale_register(const sal_Unicode * language, const sa hashCode = rtl_ustr_hashCode(language) ^ rtl_ustr_hashCode(country) ^ rtl_ustr_hashCode(variant); - auto it = g_pLocaleTable->find(hashCode); - if (it != g_pLocaleTable->end()) + auto it = g_aLocaleTable.find(hashCode); + if (it != g_aLocaleTable.end()) return it->second.get(); rtl_uString_newFromStr(&sLanguage, language); @@ -97,7 +91,7 @@ rtl_Locale * SAL_CALL rtl_locale_register(const sal_Unicode * language, const sa newLocale->HashCode = hashCode; auto ret = newLocale.get(); - g_pLocaleTable->insert(it, std::pair<sal_Int32, locale_unique_ptr>( hashCode, std::move(newLocale) ) ); + g_aLocaleTable.insert(it, std::pair<sal_Int32, locale_unique_ptr>( hashCode, std::move(newLocale) ) ); return ret; } |