]> git.eshelyaron.com Git - emacs.git/commitdiff
Transform (list) -> nil in source optimiser
authorMattias Engdegård <mattiase@acm.org>
Fri, 15 Jul 2022 19:28:30 +0000 (21:28 +0200)
committerMattias Engdegård <mattiase@acm.org>
Sat, 16 Jul 2022 10:17:32 +0000 (12:17 +0200)
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

index a24a504456233e2b9a505d6b877a0f1c487f3b84..5a138e9fee53b031ae059f00e20a3a8f43da5656 100644 (file)
@@ -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)