diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-22 08:52:59 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-22 12:07:54 +0100 |
commit | 85acc270fc670443cd700c471d9b495e12d4e6dc (patch) | |
tree | 59172f6ee9a51d92548dc64735946b4fcd2a3f7d /sal/rtl | |
parent | eea439b4b1305449616e8d0d368f3ccff1a7eca9 (diff) |
improve function-local statics in sal
Change-Id: I0853cf13162bae44cf8a5c44a4546a73f05772d9
Reviewed-on: https://gerrit.libreoffice.org/63780
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sal/rtl')
-rw-r--r-- | sal/rtl/bootstrap.cxx | 17 | ||||
-rw-r--r-- | sal/rtl/hash.cxx | 7 |
2 files changed, 9 insertions, 15 deletions
diff --git a/sal/rtl/bootstrap.cxx b/sal/rtl/bootstrap.cxx index 897de890d890..9c6675586ef9 100644 --- a/sal/rtl/bootstrap.cxx +++ b/sal/rtl/bootstrap.cxx @@ -155,10 +155,9 @@ static bool getFromCommandLineArgs( { OSL_ASSERT(value); - static NameValueVector *pNameValueVector = nullptr; - if (!pNameValueVector) + static NameValueVector nameValueVector = [&]() { - static NameValueVector nameValueVector; + NameValueVector tmp; sal_Int32 nArgCount = osl_getCommandArgCount(); for(sal_Int32 i = 0; i < nArgCount; ++ i) @@ -189,18 +188,18 @@ static bool getFromCommandLineArgs( nameValue.sValue = nameValue.sValue.copy(0,nameValue.sValue.getLength()-1); } - nameValueVector.push_back( nameValue ); + tmp.push_back( nameValue ); } } rtl_uString_release( pArg ); - } - pNameValueVector = &nameValueVector; - } + }; + return tmp; + }(); bool found = false; - for(NameValueVector::iterator ii = pNameValueVector->begin(); - ii != pNameValueVector->end(); + for(NameValueVector::iterator ii = nameValueVector.begin(); + ii != nameValueVector.end(); ++ii) { if ((*ii).sName == key) diff --git a/sal/rtl/hash.cxx b/sal/rtl/hash.cxx index e12095f3d9e5..489030f62861 100644 --- a/sal/rtl/hash.cxx +++ b/sal/rtl/hash.cxx @@ -40,12 +40,7 @@ static void rtl_str_hash_free(StringHashTable *pHash); static StringHashTable * getHashTable() { - static StringHashTable *pInternPool = nullptr; - if (!pInternPool) - { - static StringHashTable* pHash = rtl_str_hash_new(1024); - pInternPool = pHash; - } + static StringHashTable* pInternPool = rtl_str_hash_new(1024); return pInternPool; } |