[RFC] A stream buffer for wcin
Pétur Runólfsson
peturr02@ru.is
Fri Feb 21 08:02:00 GMT 2003
Nathan Myers wrote:
> Right. You don't have to be fast if ios_base::sync_with_stdio(false)
> hasn't been called.
Actually, this trivial stream buffer is much (10x) faster than the
unbuffered basic_filebuf currently used by wcin when sync_with_stdio
hasn't been called, and only 2x slower otherwise.
I tried a similar stream buffer for cin, and also got a nice speedup
there (3x).
The test program was a simple loop:
wstreambuf* buf = wcin.rdbuf();
while (buf->sbumpc() != WEOF);
> > However, if ios_base::sync_with_stdio(false) has been called,
> > there is no need to sync wcin with stdin. In that case a buffered
> > wfilebuf can be used for wcin.
>
> Or, you can derive wcinbuf from wfilebuf, and delegate to the
> base class if ios_base::sync_with_stdio(false) gets called.
I'm currently a bit sceptical about using basic_filebuf sometimes
and sometimes not because basic_filebuf uses getloc() but my
trivial stream buffer does not.
If this path were taken, the effect of wcin.imbue(loc) would depend
on whether sync_with_stdio had been called.
Petur
More information about the Libstdc++
mailing list