From ... From: Erik Naggum Subject: Re: Lisp io performance. Date: 1999/01/19 Message-ID: <3125763790062135@naggum.no>#1/1 X-Deja-AN: 434513620 References: <7810mk$1ik$1@nnrp1.dejanews.com> <781nss$kmg$1@nnrp1.dejanews.com> mail-copies-to: never Organization: Naggum Software; +47 8800 8879; http://www.naggum.no Newsgroups: comp.lang.lisp * Barry Margolin | BTW, stylistic note: any time a number outside the range -1:1, e.g. 8192, | appears multiple times in a piece of code, it's probably a candidate for | a DEFCONSTANT. In the case of this function, DEFPARAMETER might be more | appropriate, so you can experiment with different size buffers simply by | changing the value (for those of you who have wondered, this is where | DEFPARAMETER gets its name). in this case, I think it's also worth pointing out that the size of the string is still available. (length buffer) will yield 8192. FWIW, here's my cut at it: (defconstant disk-block-size 8192) (defun copy-file (from to) (with-open-file (in from :direction :input) (with-open-file (out to :direction :output :if-exists :supersde) (let ((buffer (make-array disk-block-size :element-type (stream-element-type in)))) (loop for read = (read-sequence buffer in) until (zerop read) do (write-sequence buffer out :end read)))))) #:Erik -- SIGTHTBABW: a signal sent from Unix to its programmers at random intervals to make them remember that There Has To Be A Better Way.