emacs-diffs
[Top][All Lists]
Advanced

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

emacs-29 13aa376e93 2/3: Elide broken but unnecessary `if` optimisations


From: Mattias Engdegård
Subject: emacs-29 13aa376e93 2/3: Elide broken but unnecessary `if` optimisations
Date: Fri, 16 Dec 2022 11:22:21 -0500 (EST)

branch: emacs-29
commit 13aa376e93564a8cf2ddbbcf0968c6666620db89
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    Elide broken but unnecessary `if` optimisations
    
    * lisp/emacs-lisp/byte-opt.el (byte-optimize-if):
    Remove explicit clauses purposing to simplify
    
        (if X nil t) -> (not X)
        (if X t nil) -> (not (not X))
    
    but never did so because of a coding mistake (eq instead of equal),
    found by a recently added warning.  They weren't actually needed
    thanks to the optimiser's fixpoint iteration: we eventually get the
    same results through
    
        (if X nil t) -> (if (not X) t nil) -> (if (not X) t) -> (not X)
        (if X t nil) -> (if X t) -> (not (not X))
---
 lisp/emacs-lisp/byte-opt.el | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index a7e1df3622..0da2a9b882 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -1297,11 +1297,8 @@ See Info node `(elisp) Integer Basics'."
       (if else
           `(progn ,condition ,@else)
         condition))
-     ;; (if X nil t) -> (not X)
-     ((and (eq then nil) (eq else '(t)))
-      `(not ,condition))
-     ;; (if X t [nil]) -> (not (not X))
-     ((and (eq then t) (or (null else) (eq else '(nil))))
+     ;; (if X t) -> (not (not X))
+     ((and (eq then t) (null else))
       `(not ,(byte-opt--negate condition)))
      ;; (if VAR VAR X...) -> (or VAR (progn X...))
      ((and (symbolp condition) (eq condition then))



reply via email to

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