summaryrefslogtreecommitdiff
path: root/cppuhelper
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-11-04 15:28:37 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2018-11-04 14:46:01 +0100
commite128f7806961b391cfb265a1ce009b2e036622ca (patch)
treeeda1097987f07ac6e2f507f898b71ddf929e0635 /cppuhelper
parenta2058e7516a01167c2d20ed157500b38db967c64 (diff)
replace double-checked locking patterns with thread safe local statics
Change-Id: I1bf67196e97411aeecc13ed4f91d1088a315e323 Reviewed-on: https://gerrit.libreoffice.org/62839 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'cppuhelper')
-rw-r--r--cppuhelper/source/macro_expander.cxx18
-rw-r--r--cppuhelper/source/paths.cxx21
2 files changed, 9 insertions, 30 deletions
diff --git a/cppuhelper/source/macro_expander.cxx b/cppuhelper/source/macro_expander.cxx
index 7d9b763aac05..a147d03a3e0d 100644
--- a/cppuhelper/source/macro_expander.cxx
+++ b/cppuhelper/source/macro_expander.cxx
@@ -51,23 +51,7 @@ namespace cppu
static Bootstrap const & get_unorc()
{
- static rtlBootstrapHandle s_bstrap = nullptr;
- if (! s_bstrap)
- {
- OUString iniName(getUnoIniUri());
- rtlBootstrapHandle bstrap = rtl_bootstrap_args_open( iniName.pData );
-
- ClearableMutexGuard guard( Mutex::getGlobalMutex() );
- if (s_bstrap)
- {
- guard.clear();
- rtl_bootstrap_args_close( bstrap );
- }
- else
- {
- s_bstrap = bstrap;
- }
- }
+ static rtlBootstrapHandle s_bstrap = rtl_bootstrap_args_open(getUnoIniUri().pData);
return *reinterpret_cast<Bootstrap const *>(&s_bstrap);
}
diff --git a/cppuhelper/source/paths.cxx b/cppuhelper/source/paths.cxx
index 6b7dcd443038..7ddd8b72d379 100644
--- a/cppuhelper/source/paths.cxx
+++ b/cppuhelper/source/paths.cxx
@@ -38,22 +38,17 @@ namespace {
#ifndef ANDROID
OUString get_this_libpath() {
- static OUString s_uri;
- if (s_uri.isEmpty()) {
+ static OUString s_uri = []() {
OUString uri;
- osl::Module::getUrlFromAddress(
- reinterpret_cast< oslGenericFunction >(get_this_libpath), uri);
+ osl::Module::getUrlFromAddress(reinterpret_cast<oslGenericFunction>(get_this_libpath), uri);
sal_Int32 i = uri.lastIndexOf('/');
- if (i == -1) {
- throw css::uno::DeploymentException(
- "URI " + uri + " is expected to contain a slash");
- }
- uri = uri.copy(0, i);
- osl::MutexGuard guard(osl::Mutex::getGlobalMutex());
- if (s_uri.isEmpty()) {
- s_uri = uri;
+ if (i == -1)
+ {
+ throw css::uno::DeploymentException("URI " + uri + " is expected to contain a slash");
}
- }
+ return uri.copy(0, i);
+ }();
+
return s_uri;
}
#endif