streambuf performance 200x
Martin Sebor
sebor@roguewave.com
Thu Feb 13 18:12:00 GMT 2003
Nathan Myers wrote:
> It's time to talk about fixing core streambuf performance. As it
> is, when last I measured, IIRC, it was over two orders of magnitude
> slower than stdio. We need to do something about that before we
> commit to a long period of frozen ABI.
>
> To accomplish this, we have to have absolutely minimal, inline
> implementations of basic_streambuf::sputc and sgetc. All the
> complications have to go, so that, e.g., sputc expands to the machine
> equivalent of something very like
>
> (this->pp != this->ep) ? (*this->pp++ = c) : this->overflow(c);
>
> and correspondingly for sgetc.
>
Note that this is complicated by the requirements on strstreambuf.
This program must still return 0 (it currently fails with a non-0
exit status with libstdc++):
#include <cstring>
#include <strstream>
int main ()
{
char buf[] = "abc";
std::strstreambuf sb (buf, sizeof buf, buf);
sb.freeze ();
sb.sputc ('x');
return std::strcmp (buf, "abc");
}
Regards
Martin
More information about the Libstdc++
mailing list