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 --- svtools/source/config/apearcfg.cxx | 15 ++------------- svtools/source/config/htmlcfg.cxx | 13 ++----------- 2 files changed, 4 insertions(+), 24 deletions(-) (limited to 'svtools/source') diff --git a/svtools/source/config/apearcfg.cxx b/svtools/source/config/apearcfg.cxx index b98a8cbad17e..4bfe5595012c 100644 --- a/svtools/source/config/apearcfg.cxx +++ b/svtools/source/config/apearcfg.cxx @@ -94,11 +94,8 @@ SvtTabAppearanceCfg::~SvtTabAppearanceCfg( ) const Sequence& SvtTabAppearanceCfg::GetPropertyNames() { - static Sequence aNames; - if(!aNames.getLength()) + static Sequence const aNames { - static const sal_Char* aPropNames[] = - { "Window/Drag" // 0 ,"Menu/FollowMouse" // 1 ,"Dialog/MousePositioning" // 2 @@ -107,15 +104,7 @@ const Sequence& SvtTabAppearanceCfg::GetPropertyNames() ,"FontAntiAliasing/Enabled" // 4 ,"FontAntiAliasing/MinPixelHeight" // 5 #endif - }; - const int nCount = SAL_N_ELEMENTS( aPropNames ); - aNames.realloc(nCount); - - const sal_Char** pAsciiNames = aPropNames; - OUString* pNames = aNames.getArray(); - for(int i = 0; i < nCount; ++i, ++pNames, ++pAsciiNames) - *pNames = OUString::createFromAscii( *pAsciiNames ); - } + }; return aNames; } diff --git a/svtools/source/config/htmlcfg.cxx b/svtools/source/config/htmlcfg.cxx index 5fd83ff7027d..7c78ebee4201 100644 --- a/svtools/source/config/htmlcfg.cxx +++ b/svtools/source/config/htmlcfg.cxx @@ -76,11 +76,8 @@ struct HtmlOptions_Impl const Sequence& SvxHtmlOptions::GetPropertyNames() { - static Sequence aNames; - if(!aNames.getLength()) + static Sequence const aNames { - static const char* aPropNames[] = - { "Import/UnknownTag", // 0 "Import/FontSetting", // 1 "Import/FontSize/Size_1", // 2 @@ -97,13 +94,7 @@ const Sequence& SvxHtmlOptions::GetPropertyNames() "Export/Warning", // 13 "Export/Encoding", // 14 "Import/NumbersEnglishUS" // 15 - }; - const int nCount = SAL_N_ELEMENTS(aPropNames); - aNames.realloc(nCount); - OUString* pNames = aNames.getArray(); - for(int i = 0; i < nCount; i++) - pNames[i] = OUString::createFromAscii(aPropNames[i]); - } + }; return aNames; } -- cgit