summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-02-29 20:01:26 +0000
committerMiklos Vajna <vmiklos@collabora.com>2024-03-04 08:20:13 +0100
commit1af440ac558ab19e92302c99477f20829fa6888e (patch)
treefabc28eb8f2e5d665b4c8a92823e785e2de8717d /svl
parent69a5a5ce7fb452b8a1ed1c1edf3571b1df5d7439 (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> (cherry picked from commit bc08b1fbbd00c6e4b086f6d95249e684ace6ae25) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164189 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'svl')
-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 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