From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 74851 invoked by alias); 9 Oct 2019 12:55:20 -0000 Mailing-List: contact libstdc++-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libstdc++-owner@gcc.gnu.org Received: (qmail 74835 invoked by uid 89); 9 Oct 2019 12:55:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 09 Oct 2019 12:55:19 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BB16C30860C4; Wed, 9 Oct 2019 12:55:17 +0000 (UTC) Received: from localhost (unknown [10.33.36.149]) by smtp.corp.redhat.com (Postfix) with ESMTP id 62A8160C18; Wed, 9 Oct 2019 12:55:17 +0000 (UTC) Date: Wed, 09 Oct 2019 12:55:00 -0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] PR libstdc++/78552 only construct std::locale for C locale once Message-ID: <20191009125516.GA12729@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="M9NhX3UHpAaciwkO" Content-Disposition: inline X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.12.1 (2019-06-15) X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg00032.txt.bz2 --M9NhX3UHpAaciwkO Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Content-length: 295 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. --M9NhX3UHpAaciwkO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" Content-length: 1096 commit 8551ad37ed959266b5aaeab5c29ddfe26e121060 Author: Jonathan Wakely 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 --M9NhX3UHpAaciwkO--