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]

Re: [RFC] Doubts about our istream::ignore


On Thu, May 20, 2004 at 08:36:38PM +0200, Paolo Carlini wrote:
> 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?

I agree.

> 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.

I agree.  

Of course, now that streamsize is 64 bits, it would take longer than the 
remaining lifetime of the universe (or, perhaps, the remaining fossil 
fuels) to get there.  (That assumes Moore's law will get used up, too.)

Nathan Myers
ncm@cantrip.org


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