------- Comment #14 from tstarling at wikimedia dot org 2010-09-09 02:31
(In reply to comment #11)
> So? We are not changing glibc here. The C++ library does *not* use buffering
> the synced mode, and it does otherwise, for fstreams in particular. Where do
> you think the performance difference is essentially coming from?
Sure, buffering would help, because the interface between the C++ library and
the buffer in the C library is slow. I just meant that the lack of a buffer in
C++ isn't an excuse for slowness since it should theoretically be possible for
C++ to access the buffer in the C library without much overhead.
At another level, your question is unsolved and interesting, because
while(getc(stdin)!=EOF); is much faster than cin.getline(), taking only 0.632s
of user time for the attached test case. And a loop of getc_unlocked() only
takes 0.188s of user time. So there may be opportunity for optimisation here
without resorting to fgets() or getdelim(), which as you say, suck in various
ways. I'll see if I have time for some more testing.
If I wrote a patch involving a new virtual method or two, would it be looked