op<< optimizations
Matt Austern
austern@apple.com
Mon Feb 3 19:01:00 GMT 2003
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
More information about the Libstdc++
mailing list