unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#29866: 27.0.50; cl-loop: Calculate the array length just once
@ 2017-12-27 16:10 Tino Calancha
  2017-12-27 20:13 ` Tino Calancha
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Tino Calancha @ 2017-12-27 16:10 UTC (permalink / raw)
  To: 29866; +Cc: monnier

X-Debbugs-CC: monnier@iro.umontreal.ca

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 <tino.calancha@gmail.com>
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)





^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-05-06  2:21 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-27 16:10 bug#29866: 27.0.50; cl-loop: Calculate the array length just once Tino Calancha
2017-12-27 20:13 ` Tino Calancha
2017-12-27 20:20   ` Lars Ingebrigtsen
2017-12-27 20:54 ` Stefan Monnier
2017-12-27 21:36   ` Tino Calancha
2017-12-28  1:27     ` Drew Adams
2017-12-28  1:49       ` Noam Postavsky
2017-12-28  1:52         ` Drew Adams
2017-12-28  2:39     ` Stefan Monnier
2017-12-28 17:21       ` Tino Calancha
2018-01-07 15:39   ` Tino Calancha
2020-05-06  2:21 ` Noam Postavsky

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).