From: Nathan Froyd Date: Thu, 20 Dec 2012 04:10:42 +0000 (-0500) Subject: lazily compute MIN-EXTENSION for VECTOR-PUSH-EXTEND X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=a1019cb2ccde131d2466f2d70076a00059e3c71d;p=sbcl.git lazily compute MIN-EXTENSION for VECTOR-PUSH-EXTEND This change avoids a full call to LENGTH on every call to VECTOR-PUSH-EXTEND. --- diff --git a/src/code/array.lisp b/src/code/array.lisp index 0d44b09..8a4ddfe 100644 --- a/src/code/array.lisp +++ b/src/code/array.lisp @@ -836,18 +836,17 @@ of specialized arrays is supported." (setf (%array-fill-pointer array) (1+ fill-pointer)) fill-pointer)))) -(defun vector-push-extend (new-element - vector - &optional - (min-extension - (let ((length (length vector))) - (min (1+ length) - (- array-dimension-limit length))))) - (declare (fixnum min-extension)) +(defun vector-push-extend (new-element vector &optional min-extension) + (declare (type (or null fixnum) min-extension)) (let ((fill-pointer (fill-pointer vector))) (declare (fixnum fill-pointer)) (when (= fill-pointer (%array-available-elements vector)) - (adjust-array vector (+ fill-pointer (max 1 min-extension)))) + (let ((min-extension + (or min-extension + (let ((length (length vector))) + (min (1+ length) + (- array-dimension-limit length)))))) + (adjust-array vector (+ fill-pointer (max 1 min-extension))))) ;; disable bounds checking (locally (declare (optimize (safety 0))) (setf (aref vector fill-pointer) new-element))