]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Simplify some chrono formatters
authorJonathan Wakely <jwakely@redhat.com>
Thu, 14 Dec 2023 15:29:13 +0000 (15:29 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 9 Jan 2024 17:20:29 +0000 (17:20 +0000)
commit8ae50799cd25a63fa028eb6aad4f93be1d8eeb39
tree88320eb735010eb397a3f5ad6be6746d36804452
parent0beb20c01cf7120c724f9882be41a77e970fe63d
libstdc++: Simplify some chrono formatters

I don't remember exactly why I made these bits of code reserve space in
a COW string and append to it, rather than just use the string returned
from std::format (which will undergo copy elision). The _Str_sink type
used by std::format means the string only performs a single allocation
for the formatted output, and the returned string's reference count will
be one, so won't reallocate when indexing into it. We can remove these
non-optimizations.

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (__formatter_chrono::_M_F): Simplify
handling of string returned from std::format.
(__formatter_chrono::_M_R_T): Likewise.
libstdc++-v3/include/bits/chrono_io.h