This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
RE: [RFC] A stream buffer for wcin
- From: Pétur Runólfsson <peturr02 at ru dot is>
- To: "Nathan Myers" <ncm-nospam at cantrip dot org>,<libstdc++ at gcc dot gnu dot org>
- Date: Fri, 21 Feb 2003 08:01:13 -0000
- Subject: RE: [RFC] A stream buffer for wcin
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