emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-27 de1b33f 3/5: Revert "cl-loop: Calculate the array length just o


From: Noam Postavsky
Subject: emacs-27 de1b33f 3/5: Revert "cl-loop: Calculate the array length just once"
Date: Tue, 5 May 2020 21:14:43 -0400 (EDT)

branch: emacs-27
commit de1b33f5a8c6ceee9be59285f70370c3cb2efd34
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    Revert "cl-loop: Calculate the array length just once"
    
    Don't merge to master.  This is a safe-for-release fix for Bug#40727.
---
 lisp/emacs-lisp/cl-macs.el | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 00f34d3..78d083f 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -1322,13 +1322,11 @@ For more details, see Info node `(cl)Loop Facility'.
 
               ((memq word '(across across-ref))
                (let ((temp-vec (make-symbol "--cl-vec--"))
-                      (temp-len (make-symbol "--cl-len--"))
                      (temp-idx (make-symbol "--cl-idx--")))
                  (push (list temp-vec (pop cl--loop-args)) loop-for-bindings)
-                 (push (list temp-len `(length ,temp-vec)) loop-for-bindings)
                  (push (list temp-idx -1) loop-for-bindings)
                  (push `(< (setq ,temp-idx (1+ ,temp-idx))
-                            ,temp-len)
+                            (length ,temp-vec))
                         cl--loop-body)
                  (if (eq word 'across-ref)
                      (push (list var `(aref ,temp-vec ,temp-idx))
@@ -1343,7 +1341,6 @@ For more details, see Info node `(cl)Loop Facility'.
                                    (error "Expected `of'"))))
                      (seq (cl--pop2 cl--loop-args))
                      (temp-seq (make-symbol "--cl-seq--"))
-                     (temp-len (make-symbol "--cl-len--"))
                      (temp-idx
                        (if (eq (car cl--loop-args) 'using)
                            (if (and (= (length (cadr cl--loop-args)) 2)
@@ -1354,19 +1351,16 @@ For more details, see Info node `(cl)Loop Facility'.
                  (push (list temp-seq seq) loop-for-bindings)
                  (push (list temp-idx 0) loop-for-bindings)
                  (if ref
-                      (progn
+                     (let ((temp-len (make-symbol "--cl-len--")))
                        (push (list temp-len `(length ,temp-seq))
                              loop-for-bindings)
                        (push (list var `(elt ,temp-seq ,temp-idx))
                              cl--loop-symbol-macs)
                        (push `(< ,temp-idx ,temp-len) cl--loop-body))
-                    ;; Evaluate seq length just if needed, that is, when seq 
is not a cons.
-                    (push (list temp-len (or (consp seq) `(length ,temp-seq)))
-                         loop-for-bindings)
                    (push (list var nil) loop-for-bindings)
                    (push `(and ,temp-seq
                                (or (consp ,temp-seq)
-                                    (< ,temp-idx ,temp-len)))
+                                    (< ,temp-idx (length ,temp-seq))))
                          cl--loop-body)
                    (push (list var `(if (consp ,temp-seq)
                                          (pop ,temp-seq)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]