This is the mail archive of the guile@cygnus.com mailing list for the guile project.


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

Re: readline improvements


> Cc: "ccf::satchell"@hermes.dra.hmg.gb, guile@cygnus.com
> From: Michael R Cook <mcook@cognex.com>
> Date: 20 Dec 1997 16:26:31 -0500
> 
> Every implementation of fgets I've seen has been simple repeated
> invocations of getc.  I'd be inclined to implement scm_fgets that
> way--based on getc rather than fgets.

I did that last summer; the getc version was about three times as slow
as the fgets version when I timed them.  Go figure?  [See the archives
at http://www.red-bean.com/guile/guile for the gory details.]

It stands to reason that with some work, a hand-coded getc version
could be optimized to run with reasonable speed.  I decided to skip
the extra work, and gamble that fgets on the host's system has already
been optimized pretty well.  However, if more problems show up, I'm
likely to reach the point of diminishing returns.

Anyone who wants to try optimizing scm_generic_fgets in ports.c is
welcome to.  I would not be surprised if I had overlooked some very
simple optimization that would improve its performance.  (Note that
because scm_generic_fgets is supposed to work on any kind of port, it
calls the port's fgetc function.  If it were written specifically for
stdio streams, it could use getc, which would be much faster.)