]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR libstdc++/78552 only construct std::locale for C locale once
authorJonathan Wakely <jwakely@redhat.com>
Wed, 26 Feb 2020 09:43:59 +0000 (09:43 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 26 Feb 2020 09:47:47 +0000 (09:47 +0000)
Backport from mainline
2019-10-09  Jonathan Wakely  <jwakely@redhat.com>

PR libstdc++/78552
* src/c++98/locale_init.cc (locale::classic()): Do not construct a new
locale object for every call.
(locale::_S_initialize_once()): Construct C locale here.

libstdc++-v3/ChangeLog
libstdc++-v3/src/c++98/locale_init.cc

index ab768b957c4d65434b596f7aa7465aefc5f00863..8b4637246b94afd88ab4af4bbe61b8e1cbc8ff32 100644 (file)
@@ -1,5 +1,13 @@
 2020-02-26  Jonathan Wakely  <jwakely@redhat.com>
 
+       Backport from mainline
+       2019-10-09  Jonathan Wakely  <jwakely@redhat.com>
+
+       PR libstdc++/78552
+       * src/c++98/locale_init.cc (locale::classic()): Do not construct a new
+       locale object for every call.
+       (locale::_S_initialize_once()): Construct C locale here.
+
        Backport from mainline
        2020-01-23  Jonathan Wakely  <jwakely@redhat.com>
 
index fb3d8ab972ae9dd0d9df5f9e87f60349341f2099..3ee4da3d9ad7af91c6123b35c07e4ec2cf6610c2 100644 (file)
@@ -296,7 +296,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   locale::classic()
   {
     _S_initialize();
-    return *(new (&c_locale) locale(_S_classic));
+    return *(const locale*)c_locale;
   }
 
   void
@@ -306,6 +306,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     // One reference for _S_classic, one for _S_global
     _S_classic = new (&c_locale_impl) _Impl(2);
     _S_global = _S_classic;
+    new (&c_locale) locale(_S_classic);
   }
 
   void