This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: op<< optimizations
- From: Matt Austern <austern at apple dot com>
- To: Nathan Myers <ncm-nospam at cantrip dot org>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Mon, 3 Feb 2003 10:57:31 -0800
- Subject: Re: op<< optimizations
On Monday, February 3, 2003, at 10:53 AM, Nathan Myers wrote:
I've been corresponding with Jerry Quinn about op<< optimizations.
We were talking about eliminating memcpy operations from the common
execution path. (He has some shocking measurements of memcpy, and
of memmove (used by std::copy<>).)
I sent Jerry code to determine quickly the number of characters in the
decimal expansion of an integer. To make good use of this information
will require either some unholy friend access to streambuf, or (much
better) some interface improvements. I will explain those suggested
improvements here.
A not-insubstantial part of the time spent in op<< is in copying
the formatted results into the streambuf's internal buffer. It
would be better to format directly into that buffer when we can.
To that end, I am proposing three changes to basic_streambuf<>.
I mean to propose versions of them for the next standard.
The first is the simplest: a member _M_fill(_CharT, size_t n),
with obvious semantics. It would be useful for padding out to
the field width efficiently.
You realize that unless these things get into the standard you can
only use them in specializations, right? (Dietmar pointed this problem
out: the library must work correctly with a user specialization, and a
user specialization has no obligation to provide anything but the
standardized interface.)
--Matt