This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [RFC] Strive to prefer sbumpc() to snextc()?!?
- From: Paolo Carlini <pcarlini at suse dot de>
- To: Paolo Carlini <pcarlini at suse dot de>
- Cc: Pétur Runólfsson <peturr02 at ru dot is>,libstdc++ <libstdc++ at gcc dot gnu dot org>, Nathan Myers <ncm at cantrip dot org>
- Date: Thu, 22 Apr 2004 21:14:19 +0200
- Subject: Re: [RFC] Strive to prefer sbumpc() to snextc()?!?
- References: <07D05A69A3D0C14FAEA60C3ACE8E5564028F5633@mail.ru.is> <40881403.6060309@suse.de>
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.