From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 8E71B3858296 for ; Thu, 17 Aug 2023 23:28:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8E71B3858296 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692314925; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1LPDq5rotEI9/fgAHXn133RJkSIPxkM+KuZuc6nHJ9M=; b=Fn0Q9qEoa+MCwGjtI7cQhPAtmtdCbjHxsdoIyi4YYQXobuu/OQQJ+4lo/tcLjXmlVANU/f NTDfzkUwDt5U6hjxrDB9CCIO1vyJ3pGeIJXZuepBeE8I9SmsGSEJGSv9EQhBTRK7XMrS5k gXIo15kzPAUDoK2WdmibU2AqSNuSniE= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-454-AVqqQP4ONreWE9RKxjiMwg-1; Thu, 17 Aug 2023 19:28:43 -0400 X-MC-Unique: AVqqQP4ONreWE9RKxjiMwg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3D0B12999B30; Thu, 17 Aug 2023 23:28:43 +0000 (UTC) Received: from localhost (unknown [10.42.28.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 077D96468B; Thu, 17 Aug 2023 23:28:42 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Replace global std::string objects in tzdb.cc Date: Fri, 18 Aug 2023 00:28:10 +0100 Message-ID: <20230817232843.1231279-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tested x86_64-linux. Pushed to trunk. -- >8 -- 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. --- 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 8d27726016e..0fcbf6a4824 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[] -- 2.41.0