This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
RE: [Patch] Fix istream::ignore + minor things
- From: "Damour, James A" <James dot Damour at dfa dot state dot ny dot us>
- To: "Paolo Carlini" <pcarlini at suse dot de>
- Cc: "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 25 May 2004 09:37:36 -0400
- Subject: RE: [Patch] Fix istream::ignore + minor things
Would your ignore code benefit from using __builtin_expect (see example
below)?
- if (__n != numeric_limits<streamsize>::max())
+ if (__builtin_expect(__n !=
numeric_limits<streamsize>::max(),1))
-----Original Message-----
From: Paolo Carlini [mailto:pcarlini@suse.de]
Sent: Sunday, May 23, 2004 11:50 AM
To: libstdc++
Subject: [Patch] Fix istream::ignore + minor things
Hi,
eventually I fixed ignore this way (__n is > 0 here):
- while (_M_gcount < __n
+ if (__n != numeric_limits<streamsize>::max())
+ --__n;
+ while (_M_gcount <= __n
Another possibility, would be playing with _M_gcount, inizializing it to
1 and the --_M_gcount at the end. This permits to spare the conditional
but breaks the general assumption that, at any given moment, _M_gcount
<= number extracted chars. I don't like that.
Took the occasion to tweak a few other bits, tighten some testcases and
add a new one.
Tested x86-linux.
Paolo.
////////////