From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#29866: 27.0.50; cl-loop: Calculate the array length just once Date: Wed, 27 Dec 2017 15:54:56 -0500 Message-ID: References: <87wp18179m.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1514407998 2079 195.159.176.226 (27 Dec 2017 20:53:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 27 Dec 2017 20:53:18 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 29866@debbugs.gnu.org To: Tino Calancha Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Dec 27 21:53:13 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eUIhK-0008Sa-He for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Dec 2017 21:53:10 +0100 Original-Received: from localhost ([::1]:47538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eUIjJ-0004J9-DQ for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Dec 2017 15:55:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eUIjD-0004IV-MG for bug-gnu-emacs@gnu.org; Wed, 27 Dec 2017 15:55:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eUIj9-0001EN-L6 for bug-gnu-emacs@gnu.org; Wed, 27 Dec 2017 15:55:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:45535) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eUIj9-0001Dj-FX for bug-gnu-emacs@gnu.org; Wed, 27 Dec 2017 15:55:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eUIj8-0001cI-6W for bug-gnu-emacs@gnu.org; Wed, 27 Dec 2017 15:55:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 27 Dec 2017 20:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29866 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 29866-submit@debbugs.gnu.org id=B29866.15144081006203 (code B ref 29866); Wed, 27 Dec 2017 20:55:02 +0000 Original-Received: (at 29866) by debbugs.gnu.org; 27 Dec 2017 20:55:00 +0000 Original-Received: from localhost ([127.0.0.1]:54216 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eUIj5-0001by-Kq for submit@debbugs.gnu.org; Wed, 27 Dec 2017 15:55:00 -0500 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:48728) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eUIj4-0001br-28 for 29866@debbugs.gnu.org; Wed, 27 Dec 2017 15:54:58 -0500 Original-Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id vBRKsuU2002572; Wed, 27 Dec 2017 15:54:57 -0500 Original-Received: by ceviche.home (Postfix, from userid 20848) id 9D2A266326; Wed, 27 Dec 2017 15:54:56 -0500 (EST) In-Reply-To: <87wp18179m.fsf@gmail.com> (Tino Calancha's message of "Thu, 28 Dec 2017 01:10:29 +0900") X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6188=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6188> : inlines <6289> : streams <1774348> : uri <2558440> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:141547 Archived-At: > X-Debbugs-CC: monnier@iro.umontreal.ca 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). Stefan > --8<-----------------------------cut here---------------start------------->8--- > commit 1175db5cf09eb39e7e70703f38578d31b0dd9398 > Author: Tino Calancha > 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)