]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Replace global std::string objects in tzdb.cc
authorJonathan Wakely <jwakely@redhat.com>
Thu, 17 Aug 2023 19:39:02 +0000 (20:39 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 17 Aug 2023 19:42:35 +0000 (20:42 +0100)
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

index 8d27726016ece9bfb7372ed195458b0ee9b6fc17..0fcbf6a4824e97be9e5020283856d01ca7c5bffd 100644 (file)
@@ -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[]