[Patch] Fix istream::ignore + minor things
Damour, James A
James.Damour@dfa.state.ny.us
Tue May 25 13:46:00 GMT 2004
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.
////////////
More information about the Libstdc++
mailing list