3 ms·
slurp-stream3 looks pretty sloppy... (defun slurp-stream3 (stream) (with-output-to-string (out) (let ((seq (make-array 1024 :element-type 'character
by Hexstream 18y ago
slurp-stream3 looks pretty sloppy...
(defun slurp-stream3 (stream)
(with-output-to-string (out)
(let ((seq (make-array 1024 :element-type 'character
:adjustable t
:fill-pointer 1024)))
(loop
(setf (fill-pointer seq) (read-sequence seq stream))
(when (zerop (fill-pointer seq))
(return))
(write-sequence seq out)))))
1. The array doesn't need to be adjustable because he's reading no more than 1024 characters at a time.
2. read-sequence and write-sequence ignore the fill-pointer so there's no need for it, much less initialize it to 1024 (also :fill-pointer t would have the same effect of initializing to the length of the vector). He's using the fill-pointer as a variable so he should just use a simple lexical variable.