svl/source/numbers/zforlist.cxx |   19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

New commits:
commit 1af440ac558ab19e92302c99477f20829fa6888e
Author:     Caolán McNamara <[email protected]>
AuthorDate: Thu Feb 29 20:01:26 2024 +0000
Commit:     Miklos Vajna <[email protected]>
CommitDate: Mon Mar 4 08:20:13 2024 +0100

    scope of MutexGuard can be reduced
    
    These are just locals, except for IniLnge which is set once in the
    ctor and is then immutable
    
    Change-Id: I0d8ac0c3ca729003a3575dea39b2746dfc53b4bc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164173
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>
    (cherry picked from commit bc08b1fbbd00c6e4b086f6d95249e684ace6ae25)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164189
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index fa9c83757eff..8d2d28b90b3f 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -3530,33 +3530,25 @@ SvNumberFormatterMergeMap 
SvNumberFormatter::ConvertMergeTableToMap()
     return aMap;
 }
 
-
 sal_uInt32 SvNumberFormatter::GetFormatForLanguageIfBuiltIn( sal_uInt32 
nFormat,
                                                              LanguageType 
eLnge )
 {
-    ::osl::MutexGuard aGuard( GetInstanceMutex() );
     if ( eLnge == LANGUAGE_DONTKNOW )
-    {
-        eLnge = IniLnge;
-    }
+        eLnge = IniLnge;    // IniLnge never changes
     if ( nFormat < SV_COUNTRY_LANGUAGE_OFFSET && eLnge == IniLnge )
-    {
         return nFormat;     // it stays as it is
-    }
     sal_uInt32 nOffset = nFormat % SV_COUNTRY_LANGUAGE_OFFSET;  // relative 
index
     if ( nOffset > SV_MAX_COUNT_STANDARD_FORMATS )
-    {
-        return nFormat;    // not a built-in format
-    }
+        return nFormat;     // not a built-in format
+
+    ::osl::MutexGuard aGuard( GetInstanceMutex() );
     sal_uInt32 nCLOffset = ImpGenerateCL(eLnge);    // create new standard 
formats if necessary
     return nCLOffset + nOffset;
 }
 
-
 sal_uInt32 SvNumberFormatter::GetFormatIndex( NfIndexTableOffset nTabOff,
                                               LanguageType eLnge )
 {
-    ::osl::MutexGuard aGuard( GetInstanceMutex() );
     if (nTabOff >= NF_INDEX_TABLE_ENTRIES)
         return NUMBERFORMAT_ENTRY_NOT_FOUND;
 
@@ -3566,12 +3558,11 @@ sal_uInt32 SvNumberFormatter::GetFormatIndex( 
NfIndexTableOffset nTabOff,
     if (indexTable[nTabOff] == NUMBERFORMAT_ENTRY_NOT_FOUND)
         return NUMBERFORMAT_ENTRY_NOT_FOUND;
 
+    ::osl::MutexGuard aGuard( GetInstanceMutex() );
     sal_uInt32 nCLOffset = ImpGenerateCL(eLnge);    // create new standard 
formats if necessary
-
     return nCLOffset + indexTable[nTabOff];
 }
 
-
 NfIndexTableOffset SvNumberFormatter::GetIndexTableOffset( sal_uInt32 nFormat 
) const
 {
     sal_uInt32 nOffset = nFormat % SV_COUNTRY_LANGUAGE_OFFSET;      // 
relative index

Reply via email to