bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#29866: 27.0.50; cl-loop: Calculate the array length just once


From: Tino Calancha
Subject: bug#29866: 27.0.50; cl-loop: Calculate the array length just once
Date: Thu, 28 Dec 2017 01:10:29 +0900

X-Debbugs-CC: address@hidden

It looks sensible to calculate the array length just once,
instead of recalculate it on each iteration:
--8<-----------------------------cut here---------------start------------->8---
commit 1175db5cf09eb39e7e70703f38578d31b0dd9398
Author: Tino Calancha <address@hidden>
Date:   Thu Dec 28 00:56:32 2017 +0900

    cl-loop: Calculate the array length just once
    
    * lisp/emacs-lisp/cl-macs.el (cl--parse-loop-clause):
    Dont calculate the array length on each iteration (Bug#29866).

diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index f5311041cc..f671aea399 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -1317,11 +1317,13 @@ cl--parse-loop-clause
 
               ((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))
-                            (length ,temp-vec))
+                            ,temp-len)
                         cl--loop-body)
                  (if (eq word 'across-ref)
                      (push (list var `(aref ,temp-vec ,temp-idx))

--8<-----------------------------cut here---------------end--------------->8---


In GNU Emacs 27.0.50 (build 32, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2017-12-28 built on calancha-pc
Repository revision: da94ea92bc3ba6c236b394c00e6bbb725131a149
Windowing system distributor 'The X.Org Foundation', version 11.0.11902000
System Description: Debian GNU/Linux 9.3 (stretch)





reply via email to

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