From eb0e93478e423974fe6c7c7e4d183ea8d9f0e742 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mattias=20Engdeg=C3=A5rd?= Date: Fri, 15 Jul 2022 21:28:30 +0200 Subject: [PATCH] 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. --- lisp/emacs-lisp/byte-opt.el | 5 +++++ 1 file changed, 5 insertions(+) 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) -- 2.39.2