[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: drain-input
From: |
Alex Shinn |
Subject: |
Re: drain-input |
Date: |
30 Aug 2001 02:19:30 -0400 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/21.0.104 |
>>>>> "Rob" == Rob Browning <address@hidden> writes:
Rob> Seems like you might get a lot better performance if you read
Rob> in chunks and then used string-concatenate(-reverse) from
Rob> srfi-19 or similar. Actually, if read-delimited is
Rob> implemented with special casing, you might get good results
Rob> with just (read-delimited "" port).
For the particular problem of getting the contents of a file as a
string, I ended up doing
(define (file-contents file)
(call-with-input-file file
(lambda (p)
(let* ((size (stat:size (stat p)))
(buf (make-string size)))
(read-string!/partial buf p)
buf))))
but this doesn't work for draining arbitrary ports. For this reading
by chunks or (read-delimited "" port) is probably best.
--
Alex Shinn <address@hidden>