framework/source/uielement/buttontoolbarcontroller.cxx |   15 ++++-----------
 svtools/source/uno/statusbarcontroller.cxx             |   15 ++++-----------
 svtools/source/uno/toolboxcontroller.cxx               |   15 ++++-----------
 3 files changed, 12 insertions(+), 33 deletions(-)

New commits:
commit 4578ded393f8e97ae781f63c9a1cf57669409635
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sat Apr 15 01:13:22 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sat Apr 15 03:05:26 2023 +0200

    Simplify initialized check
    
    The previous complexity did nothing useful; it allowed to have a single
    unguarded boolean value check, for the cost of releasing and acquiring
    the mutex again.
    
    Change-Id: I426304e9ef6f27ca371544951bf3cc029887019e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150437
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/framework/source/uielement/buttontoolbarcontroller.cxx 
b/framework/source/uielement/buttontoolbarcontroller.cxx
index 4972b6da7667..d94e5b0ff25f 100644
--- a/framework/source/uielement/buttontoolbarcontroller.cxx
+++ b/framework/source/uielement/buttontoolbarcontroller.cxx
@@ -90,21 +90,14 @@ void SAL_CALL ButtonToolbarController::release() noexcept
 void SAL_CALL ButtonToolbarController::initialize(
     const css::uno::Sequence< css::uno::Any >& aArguments )
 {
-    bool bInitialized( true );
-
-    {
-        SolarMutexGuard aSolarMutexGuard;
-
-        if ( m_bDisposed )
-            throw DisposedException();
+    SolarMutexGuard aSolarMutexGuard;
 
-        bInitialized = m_bInitialized;
-    }
+    if ( m_bDisposed )
+        throw DisposedException();
 
-    if ( bInitialized )
+    if ( m_bInitialized )
         return;
 
-    SolarMutexGuard aSolarMutexGuard;
     m_bInitialized = true;
 
     PropertyValue aPropValue;
diff --git a/svtools/source/uno/statusbarcontroller.cxx 
b/svtools/source/uno/statusbarcontroller.cxx
index 76387cbad0fd..6a8499a353c7 100644
--- a/svtools/source/uno/statusbarcontroller.cxx
+++ b/svtools/source/uno/statusbarcontroller.cxx
@@ -120,21 +120,14 @@ void SAL_CALL StatusbarController::release() noexcept
 
 void SAL_CALL StatusbarController::initialize( const Sequence< Any >& 
aArguments )
 {
-    bool bInitialized( true );
-
-    {
-        SolarMutexGuard aSolarMutexGuard;
-
-        if ( m_bDisposed )
-            throw DisposedException();
+    SolarMutexGuard aSolarMutexGuard;
 
-        bInitialized = m_bInitialized;
-    }
+    if ( m_bDisposed )
+        throw DisposedException();
 
-    if ( bInitialized )
+    if ( m_bInitialized )
         return;
 
-    SolarMutexGuard aSolarMutexGuard;
     m_bInitialized = true;
 
     PropertyValue aPropValue;
diff --git a/svtools/source/uno/toolboxcontroller.cxx 
b/svtools/source/uno/toolboxcontroller.cxx
index 8fe4eb37c621..b592bb25b859 100644
--- a/svtools/source/uno/toolboxcontroller.cxx
+++ b/svtools/source/uno/toolboxcontroller.cxx
@@ -163,21 +163,14 @@ css::uno::Sequence<css::uno::Type> 
ToolboxController::getTypes()
 
 void SAL_CALL ToolboxController::initialize( const Sequence< Any >& aArguments 
)
 {
-    bool bInitialized( true );
-
-    {
-        SolarMutexGuard aSolarMutexGuard;
-
-        if ( m_bDisposed )
-            throw DisposedException();
+    SolarMutexGuard aSolarMutexGuard;
 
-        bInitialized = m_bInitialized;
-    }
+    if ( m_bDisposed )
+        throw DisposedException();
 
-    if ( bInitialized )
+    if ( m_bInitialized )
         return;
 
-    SolarMutexGuard aSolarMutexGuard;
     m_bInitialized = true;
     m_bSupportVisible = false;
     PropertyValue aPropValue;

Reply via email to