fputs() is too slow
Geoff Keating
geoffk@geoffk.org
Mon Oct 30 11:21:00 GMT 2000
> 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>
More information about the Libc-alpha
mailing list