Arggh.... Good catch. Let's move the transcript operations as you suggest.
On Sun, Sep 20, 2009 at 12:14 PM, Joe Marshall <jmarsh...@alum.mit.edu> wrote: > On Sat, Sep 19, 2009 at 9:50 PM, Taylor R Campbell <campb...@mumble.net> > wrote: >> >> For SYMBOL?, I thought it was worth integrating because >> GUARANTEE-SYMBOL is called on nearly every I/O operation. >> >> It is? I don't see why it would, unless you are changing a generic >> port's line-ending or using port properties at every I/O operation. > > I'm guessing it was an unforseen consequence. Here's what happens: > > When reading or writing a string or character, a call is made to > TRANSCRIBE-CHAR or TRANSCRIBE-SUBSTRING which echoes > the character or string to the transcription port, if one exists. In order > to check for a transcription port, these routines call PORT/TRANSCRIPT > which either returns the transcription port or #F if there isn't one. > PORT/TRANSCRIPT calls PORT/GET-PROPERTY which has this > definition: > > (define (port/get-property port name default) > (guarantee-symbol name 'PORT/GET-PROPERTY) > (let ((p (assq name (port/properties port)))) > (if p > (cdr p) > default))) > > So you get an out-of-line call to GUARANTEE-SYMBOL and ASSQ on each > I/O operation. > > I think moving the transcript port from the property list to the port > itself would be worthwhile because this call chain happens a lot. It > would make ports a little bit bigger, but I don't think that's enough > to worry about. > > Alternatively, these two things would help: have a version of > port/get-property > that didn't GUARANTEE-SYMBOL. (If the key isn't a symbol, it won't be > found anyway), and do a quick check on the port/properties to see if it > is NULL? before calling out to ASSQ. (This would avoid a call on the common > case of ports without properties.) > > It'd be great to fix these up because port operations are one of the big > time sinks for SF. > > -- > ~jrm > _______________________________________________ MIT-Scheme-devel mailing list MIT-Scheme-devel@gnu.org http://lists.gnu.org/mailman/listinfo/mit-scheme-devel