public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR libstdc++/78552 only construct std::locale for C locale once
@ 2019-10-09 12:55 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2019-10-09 12:55 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 295 bytes --]

	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.

Tested x86_64-linux, committed to trunk.

This should be safe to backport too, but I'll wait a while as usual.



[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1096 bytes --]

commit 8551ad37ed959266b5aaeab5c29ddfe26e121060
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jul 2 15:31:48 2019 +0100

    PR libstdc++/78552 only construct std::locale for C locale once
    
            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.

diff --git a/libstdc++-v3/src/c++98/locale_init.cc b/libstdc++-v3/src/c++98/locale_init.cc
index e5e9d74379f..07d95dc09fd 100644
--- a/libstdc++-v3/src/c++98/locale_init.cc
+++ b/libstdc++-v3/src/c++98/locale_init.cc
@@ -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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-10-09 12:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-09 12:55 [PATCH] PR libstdc++/78552 only construct std::locale for C locale once Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).