summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-02-29 20:01:26 +0000
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-03-01 10:38:56 +0100
commitbc08b1fbbd00c6e4b086f6d95249e684ace6ae25 (patch)
tree5c5dae7713174de55eba755d44e037d596cbb170
parent25c2b4c4505060bbf207ed82036a63fee97a3689 (diff)
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 <caolan.mcnamara@collabora.com>
-rw-r--r--svl/source/numbers/zforlist.cxx19
1 files changed, 5 insertions, 14 deletions
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index bdc431efcbdf..c1a3fcb9015d 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