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]

[RFC] Doubts about our istream::ignore


Hi,

I'm studying in detail our ignore, in order to eventually implement a
performance improvement similar to that suggested by Pétur for
getline(char_type*).

Various things are puzzling me...

First, right at beginning, for an __n of type streamsize, there is:

__n = std::min(__n, numeric_limits<streamsize>::max());

isn't this basically a NOP, or the headache that I have got since this
morning is obfuscating my mind?

Then, a much more subtle one. The main loop goes like this:

while (_M_gcount < __n
       && !traits_type::eq_int_type(__c = __sb->sbumpc(), __eof))
  {
    ...

Now, according to 27.6.1.3, p24:

"... Characters are extracted until any of the following occurs:

- if n != numeric_limits<streamsize>::max(), n characters are extracted..."

But we are enforcing this rule *always*, not only when n != ... !!

In other terms, when _M_gcount becomes == __n we *always* terminate the
loop, whereas for __n == numeric_limits<streamsize>::max() we shouldn't.

Comments?

Thanks,
Paolo.


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