This is the mail archive of the
mailing list for the libstdc++ project.
Re: Doubts about in_avail vs showmanyc
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: Nathan Myers <ncm-nospam at cantrip dot org>
- Cc: "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>
- Date: Wed, 05 Mar 2003 09:38:24 +0100
- Subject: Re: Doubts about in_avail vs showmanyc
- References: <3E650DC8.email@example.com> <20030305050941.GC14657@tofu.dreamhost.com>
Nathan Myers wrote:
This should end up as:Thanks Nathan for this reply and the other.
inline streamsizeIn other words, in_avail() doesn't care if there's anything in some
streamsize __ret = this->egptr() - this->gptr();
return (__ret != 0) ? __ret : this->showmanyc();
putback cell; if there is, that's what's available without a call to
underflow(), and that's what this->gptr() points to, so that's all it
reports. In general, you can cut and _cut_ and *cut* the members of
basic_streambuf<> until they are really easy to understand (and fast).
Put all complexity into the virtuals of the derived classes where
speed is less important, because time spent there is amortized over
Note that there's no need to test for null pointers because if
one is 0, the others are 0 too and the difference is 0.
In general, "cutting and cutting" really scares me, since, until I'm
completely sure to understand
the smallest details, I'm _so_ afraid to broke something: I keep asking
myself: "if someone put
this here, there must be a reason!". A basic example are those checks
for null pointers: there are
many of them!
You'll have to review attentively any patch I wrote in the near future
and, in case, reassure me
that I'm doing the right thing.