diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-22 08:56:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-22 12:46:56 +0100 |
commit | 06ad764cfb36ece7f054ecb786cc0395346a6a68 (patch) | |
tree | f67c2045e736fbbdb67d18255380b2d9288d75e4 /svl | |
parent | a73494cf130866d4e678a1f421df56cdba7441d8 (diff) |
improve function-local statics in scripting..svtools
Change-Id: Idf3785a1fbc6fc5b8efbdc4cd363047709f3af91
Reviewed-on: https://gerrit.libreoffice.org/63782
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/misc/inettype.cxx | 18 |
1 files changed, 9 insertions, 9 deletions
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 <sal/config.h> +#include <array> #include <utility> #include <map> @@ -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<sal_Char const *, CONTENT_TYPE_LAST + 1> aMap = [&]() { + std::array<sal_Char const *, CONTENT_TYPE_LAST + 1> 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(); |