From 06ad764cfb36ece7f054ecb786cc0395346a6a68 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 22 Nov 2018 08:56:15 +0200 Subject: improve function-local statics in scripting..svtools Change-Id: Idf3785a1fbc6fc5b8efbdc4cd363047709f3af91 Reviewed-on: https://gerrit.libreoffice.org/63782 Tested-by: Jenkins Reviewed-by: Noel Grandin --- svl/source/misc/inettype.cxx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'svl') diff --git a/svl/source/misc/inettype.cxx b/svl/source/misc/inettype.cxx index 3480a55741a3..2704d949a8d5 100644 --- a/svl/source/misc/inettype.cxx +++ b/svl/source/misc/inettype.cxx @@ -19,6 +19,7 @@ #include +#include #include #include @@ -281,17 +282,16 @@ INetContentType INetContentTypes::GetContentType(OUString const & rTypeName) //static OUString INetContentTypes::GetContentType(INetContentType eTypeID) { - static sal_Char const * aMap[CONTENT_TYPE_LAST + 1]; - static bool bInitialized = false; - if (!bInitialized) + static std::array aMap = [&]() { + std::array tmp; for (std::size_t i = 0; i <= CONTENT_TYPE_LAST; ++i) - aMap[aStaticTypeNameMap[i].m_eTypeID] = aStaticTypeNameMap[i].m_pTypeName; - aMap[CONTENT_TYPE_UNKNOWN] = CONTENT_TYPE_STR_APP_OCTSTREAM; - aMap[CONTENT_TYPE_TEXT_PLAIN] = CONTENT_TYPE_STR_TEXT_PLAIN - "; charset=iso-8859-1"; - bInitialized = true; - } + tmp[aStaticTypeNameMap[i].m_eTypeID] = aStaticTypeNameMap[i].m_pTypeName; + tmp[CONTENT_TYPE_UNKNOWN] = CONTENT_TYPE_STR_APP_OCTSTREAM; + tmp[CONTENT_TYPE_TEXT_PLAIN] = CONTENT_TYPE_STR_TEXT_PLAIN + "; charset=iso-8859-1"; + return tmp; + }(); OUString aTypeName = eTypeID <= CONTENT_TYPE_LAST ? OUString::createFromAscii(aMap[eTypeID]) : OUString(); -- cgit