This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: fputs() is too slow
- To: zackw at stanford dot edu
- Subject: Re: fputs() is too slow
- From: Geoff Keating <geoffk at geoffk dot org>
- Date: Mon, 30 Oct 2000 11:21:08 -0800
- CC: libc-alpha at sources dot redhat dot com
- References: <20001030084352.I8628@wolery.stanford.edu>
> 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>