[Libreoffice-commits] core.git: comphelper/source cppuhelper/source cppu/source dbaccess/source desktop/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Sun Aug 15 17:17:37 UTC 2021
comphelper/source/misc/namedvaluecollection.cxx | 9 ++-------
cppu/source/threadpool/threadpool.cxx | 16 ++--------------
cppu/source/uno/lbenv.cxx | 5 ++---
cppuhelper/source/macro_expander.cxx | 21 +++++----------------
dbaccess/source/core/resource/core_resource.cxx | 7 -------
desktop/source/app/app.cxx | 5 ++---
desktop/source/app/officeipcthread.cxx | 9 ++-------
7 files changed, 15 insertions(+), 57 deletions(-)
New commits:
commit 00f257a7ef4f1ec52887bc379c14757e057e94c8
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Aug 13 16:13:42 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Aug 15 19:17:01 2021 +0200
rtl::Static -> thread-safe static local
Change-Id: Iac0501e6aa35cc3d8e62f6b6e68b76cf70233aae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120459
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/comphelper/source/misc/namedvaluecollection.cxx b/comphelper/source/misc/namedvaluecollection.cxx
index 0bda6c197267..f572f7136f0d 100644
--- a/comphelper/source/misc/namedvaluecollection.cxx
+++ b/comphelper/source/misc/namedvaluecollection.cxx
@@ -204,19 +204,14 @@ namespace comphelper
return false;
}
- namespace
- {
- class theEmptyDefault : public rtl::Static<Any, theEmptyDefault> {};
- }
-
-
const Any& NamedValueCollection::impl_get( const OUString& _rValueName ) const
{
+ static Any theEmptyDefault;
auto pos = maValues.find( _rValueName );
if ( pos != maValues.end() )
return pos->second;
- return theEmptyDefault::get();
+ return theEmptyDefault;
}
diff --git a/cppu/source/threadpool/threadpool.cxx b/cppu/source/threadpool/threadpool.cxx
index 86c280b4b352..512ddb095cd2 100644
--- a/cppu/source/threadpool/threadpool.cxx
+++ b/cppu/source/threadpool/threadpool.cxx
@@ -25,7 +25,6 @@
#include <unordered_map>
#include <osl/diagnose.h>
-#include <rtl/instance.hxx>
#include <sal/log.hxx>
#include <uno/threadpool.h>
@@ -43,21 +42,10 @@ namespace cppu_threadpool
rtl::Reference<ORequestThread> const & theThread): thread(theThread)
{}
- namespace {
-
- struct theDisposedCallerAdmin :
- public rtl::StaticWithInit< DisposedCallerAdminHolder, theDisposedCallerAdmin >
- {
- DisposedCallerAdminHolder operator () () {
- return std::make_shared<DisposedCallerAdmin>();
- }
- };
-
- }
-
DisposedCallerAdminHolder const & DisposedCallerAdmin::getInstance()
{
- return theDisposedCallerAdmin::get();
+ static DisposedCallerAdminHolder theDisposedCallerAdmin = std::make_shared<DisposedCallerAdmin>();
+ return theDisposedCallerAdmin;
}
DisposedCallerAdmin::~DisposedCallerAdmin()
diff --git a/cppu/source/uno/lbenv.cxx b/cppu/source/uno/lbenv.cxx
index 03dbc99eafcc..ad61cee0cf67 100644
--- a/cppu/source/uno/lbenv.cxx
+++ b/cppu/source/uno/lbenv.cxx
@@ -819,11 +819,10 @@ namespace
const OUString& getOIdPart() const { return m_sOidPart; }
};
- class theStaticOIdPart : public rtl::Static<makeOIdPart, theStaticOIdPart> {};
-
const OUString & unoenv_getStaticOIdPart()
{
- return theStaticOIdPart::get().getOIdPart();
+ static makeOIdPart theStaticOIdPart;
+ return theStaticOIdPart.getOIdPart();
}
}
diff --git a/cppuhelper/source/macro_expander.cxx b/cppuhelper/source/macro_expander.cxx
index 85c649dd437c..93f758becc12 100644
--- a/cppuhelper/source/macro_expander.cxx
+++ b/cppuhelper/source/macro_expander.cxx
@@ -69,21 +69,6 @@ OUString expandMacros(OUString const & text) {
namespace
{
-class ImplNames
-{
-private:
- Sequence<OUString> m_aNames;
-public:
- ImplNames() : m_aNames(2)
- {
- m_aNames[0] = SERVICE_NAME_A;
- m_aNames[1] = SERVICE_NAME_B;
- }
- const Sequence<OUString>& getNames() const { return m_aNames; }
-};
-
-class theImplNames : public rtl::Static<ImplNames, theImplNames> {};
-
OUString s_impl_name()
{
return IMPL_NAME;
@@ -91,7 +76,11 @@ OUString s_impl_name()
Sequence< OUString > const & s_get_service_names()
{
- return theImplNames::get().getNames();
+ static const Sequence< OUString > IMPL_NAMES {
+ SERVICE_NAME_A,
+ SERVICE_NAME_B
+ };
+ return IMPL_NAMES;
}
typedef cppu::WeakComponentImplHelper<
diff --git a/dbaccess/source/core/resource/core_resource.cxx b/dbaccess/source/core/resource/core_resource.cxx
index ecf73939eec2..864280452d92 100644
--- a/dbaccess/source/core/resource/core_resource.cxx
+++ b/dbaccess/source/core/resource/core_resource.cxx
@@ -26,13 +26,6 @@
namespace dbaccess
{
- // ResourceManager
- namespace
- {
- // access safety
- struct theResourceManagerMutex : public rtl::Static< osl::Mutex, theResourceManagerMutex > {};
- }
-
OUString ResourceManager::loadString(TranslateId pResId)
{
return Translate::get(pResId, Translate::Create("dba"));
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index ade68fd5efc0..f65f93d63f80 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -383,13 +383,12 @@ void FatalError(const OUString& sMessage)
_exit(EXITHELPER_FATAL_ERROR);
}
-struct theCommandLineArgs : public rtl::Static< CommandLineArgs, theCommandLineArgs > {};
-
}
CommandLineArgs& Desktop::GetCommandLineArgs()
{
- return theCommandLineArgs::get();
+ static CommandLineArgs theCommandLineArgs;
+ return theCommandLineArgs;
}
OUString ReplaceStringHookProc( const OUString& rStr )
diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx
index a0e6b98cc006..61827856f3e9 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -635,15 +635,10 @@ void DbusIpcThread::close() {
#endif
-namespace
-{
- class theRequestHandlerMutex
- : public rtl::Static<osl::Mutex, theRequestHandlerMutex> {};
-}
-
::osl::Mutex& RequestHandler::GetMutex()
{
- return theRequestHandlerMutex::get();
+ static ::osl::Mutex theRequestHandlerMutex;
+ return theRequestHandlerMutex;
}
void RequestHandler::SetDowning()
More information about the Libreoffice-commits
mailing list