[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Improved string writing
From: |
Ludovic Courtès |
Subject: |
Re: [PATCH] Improved string writing |
Date: |
Fri, 22 Apr 2005 09:34:36 +0200 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
Hi,
Kevin Ryde <address@hidden> writes:
> (I notice "write" style string output in iprin1() always goes
> char-by-char, it'd be nice if it scanned ahead for a char needing an
> escape, to send the non-escape block as a single lfwrite. Decent size
> runs of plain chars are probably quite likely.)
When modifying `iprin1 ()', I considered traversing the string to see if
it contained non-printable characters, and then deciding whether to
write it with a single `scm_lfwrite ()' call (if it did not contain
non-printable char) or not.
I preferred my "traverse-and-rewrite" approach (again, this really isn't
buffering) as it sounded less complex and probably more optimal in the
presence of non-printable characters. But you're welcome to prove me
wrong. ;-)
As for `display' (which Paul pointed out), it turns out that it is
already special-cased in `iprin1 ()' for strings (see
`if SCM_WRITINGP (pstate) ... else scm_lfwrite (...)'), meaning that
_displaying_ a string always leads to a single `scm_lfwrite ()' call.
IOW, even if the output port is unbuffered, displaying a string
currently leads to a single `write' syscall.
To summarize: the problem I was trying to address is only relevant to
`write' for strings. It is a significant optimization in the case of an
unbuffered output port which is the default. It's a less important
optimization if the output port is buffered.
Thanks,
Ludovic.