[Libreoffice-commits] core.git: i18npool/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sun Jul 18 19:33:13 UTC 2021


 i18npool/source/nativenumber/nativenumbersupplier.cxx |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

New commits:
commit 48d60a717a588d93e82268dc80018ea9970c4e0e
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sun Jul 18 11:46:39 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Jul 18 21:32:39 2021 +0200

    osl::Mutex->std::mutex in NativeNumberSupplier
    
    Change-Id: I5430636438723f99b584dd95be9d7cb5264a5af9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119131
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/i18npool/source/nativenumber/nativenumbersupplier.cxx b/i18npool/source/nativenumber/nativenumbersupplier.cxx
index 8541c9739e84..b337fc50f2c6 100644
--- a/i18npool/source/nativenumber/nativenumbersupplier.cxx
+++ b/i18npool/source/nativenumber/nativenumbersupplier.cxx
@@ -27,6 +27,7 @@
 #include <comphelper/processfactory.hxx>
 #include <cppuhelper/supportsservice.hxx>
 #include <map>
+#include <mutex>
 #include <memory>
 #include <string_view>
 #include <unordered_map>
@@ -70,7 +71,7 @@ namespace i18npool {
 
 namespace {
 
-struct theNatNumMutex : public rtl::Static<osl::Mutex, theNatNumMutex> {};
+std::mutex theNatNumMutex;
 
 }
 
@@ -553,7 +554,7 @@ struct Separators
 Separators getLocaleSeparators(const Locale& rLocale, const OUString& rLocStr)
 {
     // Guard the static variable below.
-    osl::MutexGuard aGuard(theNatNumMutex::get());
+    std::lock_guard aGuard(theNatNumMutex);
     // Maximum a couple hundred of pairs with 4-byte structs - so no need for smart managing
     static std::unordered_map<OUString, Separators> aLocaleSeparatorsBuf;
     auto it = aLocaleSeparatorsBuf.find(rLocStr);
@@ -598,11 +599,12 @@ OUString getNumberText(const Locale& rLocale, const OUString& rNumberString,
     // Handle also month and day names for NatNum12 date formatting
     const OUString& rNumberStr = (count == 0) ? rNumberString : sBuf.makeStringAndClear();
 
-    // Guard the static variables below.
-    osl::MutexGuard aGuard( theNatNumMutex::get());
-
     static auto xNumberText
         = css::linguistic2::NumberText::create(comphelper::getProcessComponentContext());
+
+    // Guard the static variables below.
+    std::lock_guard aGuard( theNatNumMutex );
+
     OUString numbertext_prefix;
     // default "cardinal" gets empty prefix
     if (!sNumberTextParams.empty() && sNumberTextParams != u"cardinal")


More information about the Libreoffice-commits mailing list