From: Mattias EngdegÄrd Date: Fri, 15 Jul 2022 19:28:30 +0000 (+0200) Subject: Transform (list) -> nil in source optimiser X-Git-Tag: emacs-29.0.90~1447^2~904 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=eb0e93478e423974fe6c7c7e4d183ea8d9f0e742;p=emacs.git Transform (list) -> nil in source optimiser This optimisation is already done in the code generator but performing it at this earlier stage is a useful normalising step that uncovers more opportunities. * lisp/emacs-lisp/byte-opt.el (byte-optimize-list): New. --- diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index a24a5044562..5a138e9fee5 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -1287,6 +1287,11 @@ See Info node `(elisp) Integer Basics'." `(list ,(nth 1 form)) form)) +(put 'list 'byte-optimizer #'byte-optimize-list) +(defun byte-optimize-list (form) + ;; (list) -> nil + (and (cdr form) form)) + ;; Fixme: delete-char -> delete-region (byte-coded) (put 'set 'byte-optimizer #'byte-optimize-set)