[Top][All Lists]

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

master 070c80e: Fix mistake in `quote` optimiser

From: Mattias Engdegård
Subject: master 070c80e: Fix mistake in `quote` optimiser
Date: Wed, 21 Jul 2021 05:27:21 -0400 (EDT)

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

    Fix mistake in `quote` optimiser
    Found by Pip Cet.
    * lisp/emacs-lisp/byte-opt.el (byte-optimize-quote): Fix mistake that
    made this optimiser ineffective at removing quoting of nil, t, and
    keywords.  The only obvious consequence is that we no longer need...
    (byte-optimize-form): ...a 'nil => nil normalising step here; remove.
    (byte-optimize-form-code-walker): Make the compiler warn about (quote).
 lisp/emacs-lisp/byte-opt.el | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index c9c0ac0..341643c 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -414,7 +414,7 @@ Same format as `byte-optimize--lexvars', with shared 
structure and contents.")
         (t form)))
       (`(quote . ,v)
-       (if (cdr v)
+       (if (or (not v) (cdr v))
           (byte-compile-warn "malformed quote form: `%s'"
                              (prin1-to-string form)))
        ;; Map (quote nil) to nil to simplify optimizer logic.
@@ -667,8 +667,7 @@ Same format as `byte-optimize--lexvars', with shared 
structure and contents.")
                      (byte-compile-log "  %s\t==>\t%s" old new)
                       (setq form new)
                       (not (eq new old))))))))
-  ;; Normalise (quote nil) to nil, for a single representation of constant nil.
-  (and (not (equal form '(quote nil))) form))
+  form)
 (defun byte-optimize-let-form (head form for-effect)
   ;; Recursively enter the optimizer for the bindings and body
@@ -1077,7 +1076,7 @@ See Info node `(elisp) Integer Basics'."
 (defun byte-optimize-quote (form)
   (if (or (consp (nth 1 form))
          (and (symbolp (nth 1 form))
-              (not (macroexp--const-symbol-p form))))
+              (not (macroexp--const-symbol-p (nth 1 form)))))
     (nth 1 form)))

reply via email to

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