1.0.0.8:
[sbcl.git] / src / compiler / seqtran.lisp
index 4a75395..323dcad 100644 (file)
                        (tests `(endp ,index))))
                     ((csubtypep type (specifier-type 'vector))
                      (process-vector `(length ,seq-name))
-                     (places `(aref ,seq-name index)))
+                     (places `(locally (declare (optimize (insert-array-bounds-checks 0)))
+                                (aref ,seq-name index))))
                     (t
                      (give-up-ir1-transform
                       "can't determine sequence argument type"))))
           (process-vector `(array-dimension ,into 0))))
       (when found-vector-p
         (bindings `(length (min ,@(vector-lengths))))
-        (tests `(= index length)))
+        (tests `(>= index length)))
       `(do (,@(bindings))
            ((or ,@(tests)) ,result)
          (declare ,@(declarations))
          :result '(when (array-has-fill-pointer-p result)
                    (setf (fill-pointer result) index))
          :into 'result
-         :body '(setf (aref result index) funcall-result))
+         :body '(locally (declare (optimize (insert-array-bounds-checks 0)))
+                 (setf (aref result index) funcall-result)))
        result)))
 
 \f
                                 ,n-sequence ,start ,n-end)))
          (block ,block
            (macrolet ((maybe-return ()
-                        '(let ((,element (aref ,sequence ,index)))
+                        ;; WITH-ARRAY-DATA has already performed bounds
+                        ;; checking, so we can safely elide the checks
+                        ;; in the inner loop.
+                        '(let ((,element (locally (declare (optimize (insert-array-bounds-checks 0)))
+                                           (aref ,sequence ,index))))
                            (when ,done-p-expr
                              (return-from ,block
                                (values ,element