From 86d298f87f00fe70d31a65b7e98f9b17fa80cb6b Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Fri, 2 Apr 2021 15:12:00 +0300 Subject: Simplify some static variable initializations Change-Id: I6cdd44aa66b9597ccc51fc3fd69b57485ccb3230 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113515 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- comphelper/source/misc/lok.cxx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'comphelper') 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 aAllowlist; - if (!bInitialized) - { + static const std::vector aAllowlist = [] { + std::vector 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; -- cgit