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] Strive to prefer sbumpc() to snextc()?!?


Pétur Runólfsson wrote:

The best solution may be to use neither sbumpc() nor snextc(), but
instead access the buffer directly, similar to what is already done
in __copy_streambufs:

     while (!_Traits::eq_int_type(__c, _Traits::eof()))
       {
         const size_t __n = __sbin->egptr() - __sbin->gptr();
         if (__n > 1)
           {
             const char_type* p = traits_type::find(__sbin->gptr(),
               __n, __delim);
             if (p)
                __n = p - __sbin->gptr();
             __str.append(__sbin->gptr(), __n);
             __sbin->gbump(__n);

In most cases, this should cause only a single call to append.


However, I agree that this cute solution has the potential to be the fastest one
by far ;) ... Perhaps I can implement it in a reasonable amount of time...


Thanks,
Paolo.


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