emacs-diffs
[Top][All Lists]
Advanced

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

master 9a63338 2/5: Elide lexical variables in for-effect context in sou


From: Mattias Engdegård
Subject: master 9a63338 2/5: Elide lexical variables in for-effect context in source optimiser
Date: Fri, 30 Jul 2021 04:54:07 -0400 (EDT)

branch: master
commit 9a6333811441a32e49bfd33c14f77680402cd639
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    Elide lexical variables in for-effect context in source optimiser
    
    * lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker):
    Remove for-effect uses of lexical variables.  We previously relied on
    this being done by the lapcode peephole optimiser but at source level
    it enables more optimisation opportunities.
    Keywords are elided for the same reason.
---
 lisp/emacs-lisp/byte-opt.el | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 4117533..58a08eb 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -402,19 +402,24 @@ Same format as `byte-optimize--lexvars', with shared 
structure and contents.")
         ((and for-effect
              (or byte-compile-delete-errors
                  (not (symbolp form))
-                 (eq form t)))
+                 (eq form t)
+                  (keywordp form)))
          nil)
         ((symbolp form)
          (let ((lexvar (assq form byte-optimize--lexvars)))
-           (if (cddr lexvar)            ; Value available?
-               (if (assq form byte-optimize--vars-outside-loop)
-                   ;; Cannot substitute; mark for retention to avoid the
-                   ;; variable being eliminated.
-                   (progn
-                     (setcar (cdr lexvar) t)
-                     form)
-                 (caddr lexvar))        ; variable value to use
-             form)))
+           (cond
+            ((not lexvar) form)
+            (for-effect nil)
+            ((cddr lexvar)            ; Value available?
+             (if (assq form byte-optimize--vars-outside-loop)
+                 ;; Cannot substitute; mark for retention to avoid the
+                 ;; variable being eliminated.
+                 (progn
+                   (setcar (cdr lexvar) t)
+                   form)
+               ;; variable value to use
+               (caddr lexvar)))
+            (t form))))
         (t form)))
       (`(quote . ,v)
        (if (or (not v) (cdr v))



reply via email to

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