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

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

[debbugs-tracker] bug#29866: closed (27.0.50; cl-loop: Calculate the arr


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#29866: closed (27.0.50; cl-loop: Calculate the array length just once)
Date: Sun, 07 Jan 2018 15:40:02 +0000

Your message dated Mon, 08 Jan 2018 00:39:28 +0900
with message-id <address@hidden>
and subject line Re: bug#29866: 27.0.50; cl-loop: Calculate the array length 
just once
has caused the debbugs.gnu.org bug report #29866,
regarding 27.0.50; cl-loop: Calculate the array length just once
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
29866: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=29866
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: 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)



--- End Message ---
--- Begin Message --- Subject: Re: bug#29866: 27.0.50; cl-loop: Calculate the array length just once Date: Mon, 08 Jan 2018 00:39:28 +0900 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
Stefan Monnier <address@hidden> writes:

>> X-Debbugs-CC: address@hidden
>
> Thanks.
>
>> It looks sensible to calculate the array length just once,
>> instead of recalculate it on each iteration:
>
> I tend to agree, but I don't know very much about the intended semantics
> of Common Lisp's `loop` macro, nor about cl-loop's implementation (tho
> I admit I did mess with it without being really sure what I was doing).
Ok, let's do it.
Pushed to master branch as commit 'cl-loop: Calculate the array length just 
once'
(bfca19e475c01f13dbacc7f8b7bb1aecf46cb7e4)


--- End Message ---

reply via email to

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