From: Mattias EngdegÄrd Date: Tue, 2 Nov 2021 13:48:55 +0000 (+0100) Subject: Optimise (cond) => nil at source level X-Git-Tag: emacs-29.0.90~3671^2~280 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=493fde95bed6c65e049b8e664837397546847b37;p=emacs.git Optimise (cond) => nil at source level * lisp/emacs-lisp/byte-opt.el (byte-optimize-cond): Optimise clause-free `cond`, which can arise from earlier transformations. This enables further optimisations. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases): Add test cases. --- diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index 9b3b2e5ce14..9c64083b64b 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -1327,7 +1327,7 @@ See Info node `(elisp) Integer Basics'." (list 'or (car (car clauses)) (byte-optimize-cond (cons (car form) (cdr (cdr form))))) - form)) + (and clauses form))) form)) (defun byte-optimize-if (form) diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index a6e224b3d2c..41edc1f8289 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el @@ -640,6 +640,9 @@ inner loops respectively." (f (list (lambda (x) (setq a x))))) (funcall (car f) 3) (list a b)) + + (cond) + (mapcar (lambda (x) (cond ((= x 0)))) '(0 1)) ) "List of expressions for cross-testing interpreted and compiled code.")