linguistic/source/misc.cxx |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

New commits:
commit 7458cb8d13b2893ccbfb648198319cc3a73d7e50
Author:     Noel Grandin <[email protected]>
AuthorDate: Sat Sep 10 19:25:04 2022 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Mon Sep 12 10:13:54 2022 +0200

    no need to allocate this on the heap
    
    Change-Id: I33a85dfd8108c2131aa6d2a9b94d0b2c3d86bce8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139782
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/linguistic/source/misc.cxx b/linguistic/source/misc.cxx
index de2bc96860ee..dc4c17ce8430 100644
--- a/linguistic/source/misc.cxx
+++ b/linguistic/source/misc.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <memory>
+#include <optional>
 #include <sal/log.hxx>
 #include <svl/lngmisc.hxx>
 #include <ucbhelper/content.hxx>
@@ -64,10 +65,10 @@ osl::Mutex & GetLinguMutex()
 
 const LocaleDataWrapper & GetLocaleDataWrapper( LanguageType nLang )
 {
-    static std::unique_ptr<LocaleDataWrapper> xLclDtaWrp;
-    if (!xLclDtaWrp || xLclDtaWrp->getLoadedLanguageTag().getLanguageType() != 
nLang)
-        xLclDtaWrp.reset(new LocaleDataWrapper(LanguageTag( nLang )));
-    return *xLclDtaWrp;
+    static std::optional<LocaleDataWrapper> oLclDtaWrp;
+    if (!oLclDtaWrp || oLclDtaWrp->getLoadedLanguageTag().getLanguageType() != 
nLang)
+        oLclDtaWrp.emplace(LanguageTag( nLang ));
+    return *oLclDtaWrp;
 }
 
 LanguageType LinguLocaleToLanguage( const css::lang::Locale& rLocale )

Reply via email to