public inbox for
 help / color / mirror / Atom feed
* [committed] libstdc++: Replace global std::string objects in
@ 2023-08-17 23:28 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2023-08-17 23:28 UTC (permalink / raw)
  To: libstdc++, gcc-patches

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 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.


	* src/c++20/ (tzdata_file, leaps_file): Change type to
 libstdc++-v3/src/c++20/ | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/src/c++20/ b/libstdc++-v3/src/c++20/
index 8d27726016e..0fcbf6a4824 100644
--- a/libstdc++-v3/src/c++20/
+++ b/libstdc++-v3/src/c++20/
@@ -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";
 // Static copy of tzdata.zi embedded in the library as tzdata_chars[]

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

only message in thread, other threads:[~2023-08-17 23:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-17 23:28 [committed] libstdc++: Replace global std::string objects in 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).