[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: file i/o and clos objects...
- To: firstname.lastname@example.org (Mike Meehan)
- Subject: Re: file i/o and clos objects...
- From: bill (Bill St. Clair)
- Date: Mon, 04 Nov 91 12:19:28
- Cc: Info-MCL@cambridge.apple.com
- Sender: bill
> Date: Sun, 3 Nov 91 17:11:08 PST
> From: email@example.com (Mike Meehan)
> To: Info-MCL@cambridge.apple.com
> Subject: file i/o and clos objects...
> Is there a way, (without resorting to the toolbox) to increase the buffer
> size used with "read-line"? Using read-line to count the number of lines
> in the file seems to be a real disk basher...read-line is hitting the disk
> about every 3rd read-line, which for a 4-5k line file is a real workout...
> Is there a straightforward way to use binary file i/o using :element-type
> '(unsigned-byte 8192) to read in, say 1k???
read-line uses the standard buffers that any file I/O uses. I believe
they are 512 bytes long. I doubt that the buffer size is your
problem, however. READ-LINE has a fair amount of overhead in order
to do rubout handling on interactive streams. See if the following
works faster for you:
(defun make-read-line-string ()
(make-array 256 :element-type 'character :fill-pointer 0 :adjustable t))
(defvar *read-line-string* (make-read-line-string))
(defun non-interactive-read-line (stream &optional
(eof-error-p t) eof-value)
(let ((s *read-line-string*)
(unless s (setq s (make-read-line-string)))
(if (stream-eofp stream)
(error "EOF on ~s" stream)
(multiple-value-bind (reader arg) (stream-reader stream)
(setf (fill-pointer s) 0)
(when (or (null (setq ch (funcall reader arg)))
(eq ch #\newline))
(vector-push-extend ch s))
(values (ensure-simple-string s) (null ch))))))