mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-18 16:44:57 +08:00
e4fe6dba90
On the libsdc++ mailing list Lewis Hyatt pointed out the performance overhead of using sputn in stream inserters, rather than writing directly to the streambuf's put area: https://gcc.gnu.org/pipermail/libstdc++/2021-July/052877.html As Lewis noted, the standard explicitly requires a call to sputn for inserting a std::basic_string_view or std::basic_string. But for inserting single characters or null-terminated strings it is more vague, and so we can improve performance by not using the __ostream_insert function. This is a minimal change that avoids __ostream_insert for single characters. We can use the unformatted basic_ostream::put(charT) function when we don't need the additional effects of a formatted output function (i.e. padding and resetting the width). The put function will insert into the buffer if possible, and only make a virtual call (to overflow) if the buffer is full. We could also avoid sputn when inserting null-terminated character strings, but that would require using a new function for inserting null-terminated strings, so the existing code using sputn is still used for basic_string and basic_string_view. My preference is to leave that for now, and try to improve the standard. We could either remove the requirement to call sputn, or allow sputn to write directly to the buffer instead of calling xsputn. libstdc++-v3/ChangeLog: * include/std/ostream (operator<<(basic_ostream&, charT)): Use unformatted input if no padding is needed. (operator<<(basic_ostream<char>&, char)): Likewise. |
||
---|---|---|
.. | ||
config | ||
doc | ||
include | ||
libsupc++ | ||
po | ||
python | ||
scripts | ||
src | ||
testsuite | ||
acinclude.m4 | ||
aclocal.m4 | ||
ChangeLog | ||
ChangeLog-1998 | ||
ChangeLog-1999 | ||
ChangeLog-2000 | ||
ChangeLog-2001 | ||
ChangeLog-2002 | ||
ChangeLog-2003 | ||
ChangeLog-2004 | ||
ChangeLog-2005 | ||
ChangeLog-2006 | ||
ChangeLog-2007 | ||
ChangeLog-2008 | ||
ChangeLog-2009 | ||
ChangeLog-2010 | ||
ChangeLog-2011 | ||
ChangeLog-2012 | ||
ChangeLog-2013 | ||
ChangeLog-2014 | ||
ChangeLog-2015 | ||
ChangeLog-2016 | ||
ChangeLog-2017 | ||
ChangeLog-2018 | ||
ChangeLog-2019 | ||
ChangeLog-2020 | ||
ChangeLog-2021 | ||
config.h.in | ||
configure | ||
configure.ac | ||
configure.host | ||
crossconfig.m4 | ||
fragment.am | ||
linkage.m4 | ||
Makefile.am | ||
Makefile.in | ||
README |
file: libstdc++-v3/README New users may wish to point their web browsers to the file index.html in the 'doc/html' subdirectory. It contains brief building instructions and notes on how to configure the library in interesting ways.