mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-14 18:10:32 -08:00
Optimise (cons X nil) to (list X)
* lisp/emacs-lisp/byte-opt.el (byte-optimize-cons): New function.
This commit is contained in:
parent
c3b44858dc
commit
a517b77ffe
1 changed files with 8 additions and 0 deletions
|
|
@ -1269,6 +1269,14 @@ See Info node `(elisp) Integer Basics'."
|
|||
form)
|
||||
form))
|
||||
|
||||
(put 'cons 'byte-optimizer #'byte-optimize-cons)
|
||||
(defun byte-optimize-cons (form)
|
||||
;; (cons X nil) => (list X)
|
||||
(if (and (= (safe-length form) 3)
|
||||
(null (nth 2 form)))
|
||||
`(list ,(nth 1 form))
|
||||
form))
|
||||
|
||||
;; Fixme: delete-char -> delete-region (byte-coded)
|
||||
;; optimize string-as-unibyte, string-as-multibyte, string-make-unibyte,
|
||||
;; string-make-multibyte for constant args.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue