[RFC] Strive to prefer sbumpc() to snextc()?!?
Paolo Carlini
pcarlini@suse.de
Thu Apr 22 19:15:00 GMT 2004
Paolo Carlini wrote:
> And, more general, isn't true that sbumpc() + sungetc() has to be
> always equivalent to sgetc()?
More in detail, Langer & Kreft, p. 228-229, discuss explicitly this
point when designing an
unbuffered stream buffer:
"As mentioned above, input functions and putback support are related. A
call to sbumpc()
followed by sungetc() must have the same effect as invocation of
sgetc(). For this reason,
we must also implement pbackfail(), because it is called by sungetc().
The default implementation
of pbackfail() does not work, because it produces a decrement in the
next pointer, which is
not possible in the unbuffered case"
I agree with that point of view: irrespective of the neat performance
advantages (I have
checked that is 2x both on x86 and on x86_64, closing the gap with stdio
reported by
15002), if someone wants to design a completely unbuffered buffer, his
sungetc() will
not work if he doesn't provide a consistent pbackfail()!!
Paolo.
More information about the Libstdc++
mailing list