------- Comment #21 from jakub at gcc dot gnu dot org  2010-09-09 15:07 -------
#if  __GNUC__ >= 3
# define _IO_BE(expr, res) __builtin_expect ((expr), res)
#else
# define _IO_BE(expr, res) (expr)
#endif

#define _IO_getc_unlocked(_fp) \
       (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \
        ? __uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
...
__STDIO_INLINE int
getc_unlocked (FILE *__fp)
{
  return _IO_getc_unlocked (__fp);
}

i.e. if getc_unlocked is called directly, it should be very fast, unless the
underlying stream is unbuffered.  This is direct access to the buffer, just STL
getline couldn't use memchr.

Anyway, not sure which STL getline we are talking about here, because e.g.
src/istream.cc getline seems to access the stdio buffer directly:
                  streamsize __size = std::min(streamsize(__sb->egptr()
                                                          - __sb->gptr()),
                                               streamsize(__n - _M_gcount
                                                          - 1));
                  if (__size > 1)
                    {
                      const char_type* __p = traits_type::find(__sb->gptr(),
                                                               __size,
                                                               __delim);


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45574

Reply via email to