From 0180c8b0a755d2381b56e33afbe2881cc7af7d69 Mon Sep 17 00:00:00 2001 From: Juan Jose Garcia Ripoll Date: Mon, 27 Sep 2010 10:25:22 +0200 Subject: [PATCH] Optimized LOOP-REPEAT to have the same quality of code as in LOOP-FOR-IN --- src/lsp/loop2.lsp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lsp/loop2.lsp b/src/lsp/loop2.lsp index 020057b07..8ae6a419c 100755 --- a/src/lsp/loop2.lsp +++ b/src/lsp/loop2.lsp @@ -120,7 +120,8 @@ ;;;; Miscellaneous Environment Things - +(defmacro loop-unsafe (&rest x) + `(locally (declare (ext:assume-right-type)) ,@x)) ;;;The LOOP-Prefer-POP feature makes LOOP generate code which "prefers" to use POP or ;;; its obvious expansion (prog1 (car x) (setq x (cdr x))). Usually this involves @@ -1649,10 +1650,7 @@ collected result will be returned as the value of the LOOP." (let* ((form (loop-get-form)) (type (if (fixnump form) 'fixnum 'real)) (var (loop-make-variable (gensym) form type)) - #-ecl - (form `(when (minusp (decf ,var)) (go end-loop))) - #+ecl ;; ECL 10.9.1 has a problem with optimizing (+ ...) - (form `(when (minusp (setf ,var (1- ,var))) (go end-loop)))) + (form `(loop-unsafe (when (minusp (decf ,var)) (go end-loop))))) (push form *loop-before-loop*) (push form *loop-after-body*) ;; FIXME: What should @@ -2031,6 +2029,7 @@ collected result will be returned as the value of the LOOP." (setq endform (loop-typed-init indexv-type) inclusive-iteration t)) (when endform (setq testfn (if inclusive-iteration '< '<=))) (setq step (if (eql stepby 1) `(1- ,indexv) `(- ,indexv ,stepby))))) + (setq step `(loop-unsafe ,step)) (when testfn (setq test (hide-variable-reference t indexv `(,testfn ,indexv ,endform)))) (when step-hack (setq step-hack `(,variable ,(hide-variable-reference indexv-user-specified-p indexv step-hack))))