This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]