From 3b26fc0117c19cd2da805c702c85a44bcd508fc5 Mon Sep 17 00:00:00 2001 From: Juho Snellman Date: Thu, 27 Oct 2005 23:42:07 +0000 Subject: [PATCH] 0.9.6.4: Several micro-optimizations to FD-STREAM-READ-N-CHARACTERS/FOO for fixed-width encodings. --- NEWS | 3 +++ src/code/fd-stream.lisp | 30 +++++++++++++++--------------- version.lisp-expr | 2 +- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/NEWS b/NEWS index 77dd7fb..027bc54 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,7 @@ ;;;; -*- coding: utf-8; -*- +changes in sbcl-0.9.7 relative to sbcl-0.9.6: + * optimization: performance improvements to READ-LINE + changes in sbcl-0.9.6 relative to sbcl-0.9.5: * bug fix: add a workaround to SBCL looping infinitely at startup on Linux kernels with apparently buggy implementations of personality(). diff --git a/src/code/fd-stream.lisp b/src/code/fd-stream.lisp index 0ef85b1..27ece7d 100644 --- a/src/code/fd-stream.lisp +++ b/src/code/fd-stream.lisp @@ -1026,41 +1026,41 @@ (tail (fd-stream-obuf-tail stream))) ,out-expr)) (defun ,in-function (stream buffer start requested eof-error-p - &aux (total-copied 0)) + &aux (index start) (end (+ start requested))) (declare (type fd-stream stream)) - (declare (type index start requested total-copied)) + (declare (type index start requested index end)) (declare (type (simple-array character (#.+ansi-stream-in-buffer-length+)) buffer)) (let ((unread (fd-stream-unread stream))) (when unread - (setf (aref buffer start) unread) + (setf (aref buffer index) unread) (setf (fd-stream-unread stream) nil) (setf (fd-stream-listen stream) nil) - (incf total-copied))) + (incf index))) (do () (nil) (let* ((head (fd-stream-ibuf-head stream)) (tail (fd-stream-ibuf-tail stream)) (sap (fd-stream-ibuf-sap stream))) - (declare (type index head tail)) + (declare (type index head tail) + (type system-area-pointer sap)) ;; Copy data from stream buffer into user's buffer. - (do () - ((or (= tail head) (= requested total-copied))) + (dotimes (i (min (truncate (- tail head) ,size) + (- end index))) + (declare (optimize speed)) (let* ((byte (sap-ref-8 sap head))) - (when (> ,size (- tail head)) - (return)) - (setf (aref buffer (+ start total-copied)) ,in-expr) - (incf total-copied) + (setf (aref buffer index) ,in-expr) + (incf index) (incf head ,size))) (setf (fd-stream-ibuf-head stream) head) ;; Maybe we need to refill the stream buffer. - (cond ( ;; If there were enough data in the stream buffer, we're done. - (= total-copied requested) - (return total-copied)) + (cond ( ;; If there was enough data in the stream buffer, we're done. + (= index end) + (return (- index start))) ( ;; If EOF, we're done in another way. (null (catch 'eof-input-catcher (refill-buffer/fd stream))) (if eof-error-p (error 'end-of-file :stream stream) - (return total-copied))) + (return (- index start)))) ;; Otherwise we refilled the stream buffer, so fall ;; through into another pass of the loop. )))) diff --git a/version.lisp-expr b/version.lisp-expr index 98bb3bd..cd1d6cd 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"0.9.6.3" +"0.9.6.4" -- 1.7.10.4