summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-04-02 15:12:00 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-04-02 17:22:21 +0200
commit86d298f87f00fe70d31a65b7e98f9b17fa80cb6b (patch)
tree0b7a389105ead641d092e56ff6fb1d49180f6265 /comphelper
parent711ec7b6c71410b850cdf6d1411d054ca34ec5a0 (diff)
Simplify some static variable initializations
Change-Id: I6cdd44aa66b9597ccc51fc3fd69b57485ccb3230 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113515 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/misc/lok.cxx14
1 files changed, 6 insertions, 8 deletions
diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx
index 796a3dc3b839..fe7c742e4ec3 100644
--- a/comphelper/source/misc/lok.cxx
+++ b/comphelper/source/misc/lok.cxx
@@ -214,10 +214,8 @@ bool isAllowlistedLanguage(const OUString& lang)
(void) lang;
return true;
#else
- static bool bInitialized = false;
- static std::vector<OUString> aAllowlist;
- if (!bInitialized)
- {
+ static const std::vector<OUString> aAllowlist = [] {
+ std::vector<OUString> aList;
// coverity[tainted_data] - we trust the contents of this variable
const char* pAllowlist = getenv("LOK_ALLOWLIST_LANGUAGES");
if (pAllowlist)
@@ -231,16 +229,16 @@ bool isAllowlistedLanguage(const OUString& lang)
continue;
std::cerr << s << " ";
- aAllowlist.emplace_back(OStringToOUString(s.c_str(), RTL_TEXTENCODING_UTF8));
+ aList.emplace_back(OStringToOUString(s.c_str(), RTL_TEXTENCODING_UTF8));
}
std::cerr << std::endl;
}
- if (aAllowlist.empty())
+ if (aList.empty())
std::cerr << "No language allowlisted, turning off the language support." << std::endl;
- bInitialized = true;
- }
+ return aList;
+ }();
if (aAllowlist.empty())
return false;