This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


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

Re: fputs() is too slow


> From: "Zack Weinberg" <zackw@stanford.edu>
> Date: Mon, 30 Oct 2000 08:43:52 -0800

> _IO_sputn dispatches to _IO_new_file_xsputn, which is three pages of
> spaghetti.

I don't see why the 'three pages of spaghetti' should be significantly
slower than calling _IO_putc_unlocked twice.  It looks like

  count = f->_IO_write_end - f->_IO_write_ptr; /* Space available. */
  if ((f->_flags & _IO_LINE_BUF) && (f->_flags & _IO_CURRENTLY_PUTTING))
     [this code should be skipped as the conditional is FALSE for files]
  /* Then fill the buffer. */
  if (count > 0)
    {
      if (count > to_do)
        count = to_do;          [ This should nearly always happen ]
      if (count > 20)
        [this code should be skipped for short strings]
      else
        {
          register char *p = f->_IO_write_ptr;
          register int i = (int) count;
          while (--i >= 0)
            *p++ = *s++;
          f->_IO_write_ptr = p;
        }
      to_do -= count;
    }
  if (to_do + must_flush > 0)
    [this code should rarely happen]
  return n - to_do;

-- 
- Geoffrey Keating <geoffk@cygnus.com>

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