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] Strive to prefer sbumpc() to snextc()?!?


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.


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