From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 42D403855586; Tue, 22 Aug 2023 11:46:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 42D403855586 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692704814; bh=pg0MPE0QfyUADGBluthCbpdgPxD8HCD0DE7i1cNsPlQ=; h=From:To:Subject:Date:From; b=sBnORlXg5Ii0ku4Y8U19177q74NH6sKLqyMudLjvxL32oiW0Ca4mlsajTyLUiZXVI lQVK9/IEKXHUdXlRPNb+AKl+gJVVOiGLD6OiMqS7dkiSNxdHRqIyQ0DyQt9UPe+tx1 ECCatJUK03GjcSsDKy1i7YFyIHCSulRXUVWckNzI= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-7741] libstdc++: Replace global std::string objects in tzdb.cc X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-13 X-Git-Oldrev: bf5f8808f0c2876212d7ab77a504dd669d2cb54c X-Git-Newrev: 3f4caf5e1e4031151d727c3e8f65e78b692cedd6 Message-Id: <20230822114654.42D403855586@sourceware.org> Date: Tue, 22 Aug 2023 11:46:54 +0000 (GMT) List-Id: https://gcc.gnu.org/g:3f4caf5e1e4031151d727c3e8f65e78b692cedd6 commit r13-7741-g3f4caf5e1e4031151d727c3e8f65e78b692cedd6 Author: Jonathan Wakely Date: Thu Aug 17 20:39:02 2023 +0100 libstdc++: Replace global std::string objects in tzdb.cc When the library is built with --disable-libstdcxx-dual-abi the only type of std::string supported is the COW string, and the two global std::string objects in tzdb.cc have to allocate memory. I added them thinking they would fit in the SSO string buffer, but that's not the case when the library only uses COW strings. Replace them with string_view objects to avoid any allocations. libstdc++-v3/ChangeLog: * src/c++20/tzdb.cc (tzdata_file, leaps_file): Change type to std::string_view. (cherry picked from commit d82a85b6161cbeebfe3de5d3d4cdd355e4617e69) Diff: --- libstdc++-v3/src/c++20/tzdb.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/src/c++20/tzdb.cc b/libstdc++-v3/src/c++20/tzdb.cc index 8d27726016ec..0fcbf6a4824e 100644 --- a/libstdc++-v3/src/c++20/tzdb.cc +++ b/libstdc++-v3/src/c++20/tzdb.cc @@ -1078,8 +1078,8 @@ namespace std::chrono } // N.B. Leading slash as required by zoneinfo_file function. - const string tzdata_file = "/tzdata.zi"; - const string leaps_file = "/leapseconds"; + const string_view tzdata_file = "/tzdata.zi"; + const string_view leaps_file = "/leapseconds"; #ifdef _GLIBCXX_STATIC_TZDATA // Static copy of tzdata.zi embedded in the library as tzdata_chars[]