diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-21 11:46:43 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-21 12:28:23 +0100 |
commit | 48314f25241e014a634dd5371543b90137ffd2bc (patch) | |
tree | c55d6ef485fee3941bc1d3becb106d0dd77e7f2f /comphelper/source/misc | |
parent | e41667762bfff43f95d1ee71b2d67903e4fdab4e (diff) |
improve function-local statics in basic..cui
Change-Id: If737e8478f6f1c8fffb060ce132d80e0f07ef8ee
Reviewed-on: https://gerrit.libreoffice.org/63701
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper/source/misc')
-rw-r--r-- | comphelper/source/misc/backupfilehelper.cxx | 26 | ||||
-rw-r--r-- | comphelper/source/misc/threadpool.cxx | 7 |
2 files changed, 14 insertions, 19 deletions
diff --git a/comphelper/source/misc/backupfilehelper.cxx b/comphelper/source/misc/backupfilehelper.cxx index 315fccb1c501..4c7917e96015 100644 --- a/comphelper/source/misc/backupfilehelper.cxx +++ b/comphelper/source/misc/backupfilehelper.cxx @@ -2044,29 +2044,25 @@ namespace comphelper const std::vector< OUString >& BackupFileHelper::getCustomizationDirNames() { - static std::vector< OUString > aDirNames; - - if (aDirNames.empty()) + static std::vector< OUString > aDirNames = { - aDirNames.emplace_back("config"); // UI config stuff - aDirNames.emplace_back("registry"); // most of the registry stuff - aDirNames.emplace_back("psprint"); // not really needed, can be abandoned - aDirNames.emplace_back("store"); // not really needed, can be abandoned - aDirNames.emplace_back("temp"); // not really needed, can be abandoned - aDirNames.emplace_back("pack"); // own backup dir - } + "config", // UI config stuff + "registry", // most of the registry stuff + "psprint", // not really needed, can be abandoned + "store", // not really needed, can be abandoned + "temp", // not really needed, can be abandoned + "pack" // own backup dir + }; return aDirNames; } const std::vector< OUString >& BackupFileHelper::getCustomizationFileNames() { - static std::vector< OUString > aFileNames; - - if (aFileNames.empty()) + static std::vector< OUString > aFileNames = { - aFileNames.emplace_back("registrymodifications.xcu"); // personal registry stuff - } + "registrymodifications.xcu" // personal registry stuff + }; return aFileNames; } diff --git a/comphelper/source/misc/threadpool.cxx b/comphelper/source/misc/threadpool.cxx index e66d1d18f24e..46c144af8dfd 100644 --- a/comphelper/source/misc/threadpool.cxx +++ b/comphelper/source/misc/threadpool.cxx @@ -109,8 +109,7 @@ ThreadPool& ThreadPool::getSharedOptimalPool() sal_Int32 ThreadPool::getPreferredConcurrency() { - static sal_Int32 ThreadCount = 0; - if (ThreadCount == 0) + static sal_Int32 ThreadCount = [&]() { const sal_Int32 nHardThreads = std::max(std::thread::hardware_concurrency(), 1U); sal_Int32 nThreads = nHardThreads; @@ -122,8 +121,8 @@ sal_Int32 ThreadPool::getPreferredConcurrency() } nThreads = std::min(nHardThreads, nThreads); - ThreadCount = std::max<sal_Int32>(nThreads, 1); - } + return std::max<sal_Int32>(nThreads, 1); + }(); return ThreadCount; } |