]> 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, 9 Oct 2019 12:55:39 +0000 (13:55 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 9 Oct 2019 12:55:39 +0000 (13:55 +0100)
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.

From-SVN: r276758

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

index 7f08a552376dc06c6335d0105d4148e6eac2e2e8..47f0ce86d968784b52e6f6780bae8ff4cad719a7 100644 (file)
@@ -1,3 +1,10 @@
+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.
+
 2019-10-08  Jonathan Wakely  <jwakely@redhat.com>
 
        * doc/Makefile.am (doc-html-docbook-regenerate): New target.
index e5e9d74379f5c34ca829b7667b553335abbd2952..07d95dc09fd8d245d2b08429621558bcee59f857 100644 (file)
@@ -303,7 +303,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   locale::classic()
   {
     _S_initialize();
-    return *(new (&c_locale) locale(_S_classic));
+    return *(const locale*)c_locale;
   }
 
   void
@@ -313,6 +313,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