[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: drain-input
From: |
Rob Browning |
Subject: |
Re: drain-input |
Date: |
Wed, 29 Aug 2001 22:45:05 -0500 |
User-agent: |
Gnus/5.090004 (Oort Gnus v0.04) Emacs/20.7 |
Neil Jerram <address@hidden> writes:
> Here's a procedure that does what I expected `drain-input' to be. I
> use it often in connection with `open-input-pipe':
>
> (define (drain-output port)
> (let loop ((chars '())
> (next (read-char port)))
> (if (eof-object? next)
> (list->string (reverse! chars))
> (loop (cons next chars)
> (read-char port)))))
Seems like you might get a lot better performance if you read in
chunks and then used string-concatenate(-reverse) from srfi-19 or
similar. Actually, if read-delimited is implemented with special
casing, you might get good results with just (read-delimited "" port).
(As an aside, I thought we had a "read-bytes" call, but I don't see
it. Is %read-delimited! with no delimiter the only way to get N
bytes from a port as a string?)
--
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG=1C58 8B2C FB5E 3F64 EA5C 64AE 78FE E5FE F0CB A0AD