diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2023-01-12 14:07:45 +0100 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2023-01-16 19:42:31 +0100 |
commit | 2a85d7a07c16dd854490b5eff72930d4a80b1415 (patch) | |
tree | faefd1f985d871d82ddf89305fea5b5a9cc76e2b /lisp/emacs-lisp/byte-opt.el | |
parent | 77659bd46345b86159d8a5d4b6f4993ec20c30a6 (diff) | |
download | emacs-2a85d7a07c16dd854490b5eff72930d4a80b1415.tar.gz emacs-2a85d7a07c16dd854490b5eff72930d4a80b1415.tar.bz2 emacs-2a85d7a07c16dd854490b5eff72930d4a80b1415.zip |
Optimise `apply` with `cons` in tail argument
* lisp/emacs-lisp/byte-opt.el (byte-optimize-apply): Transform
(apply F ... (cons X Y)) -> (apply F ... X Y)
This pattern is seen both in hand-written code and in backquote
expansions.
Diffstat (limited to 'lisp/emacs-lisp/byte-opt.el')
-rw-r--r-- | lisp/emacs-lisp/byte-opt.el | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index d7a0d851e01..039cebedb44 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -1380,6 +1380,9 @@ See Info node `(elisp) Integer Basics'." ;; (apply F ... (list X Y ...)) -> (funcall F ... X Y ...) ((eq (car-safe last) 'list) `(funcall ,fn ,@(butlast (cddr form)) ,@(cdr last))) + ;; (apply F ... (cons X Y)) -> (apply F ... X Y) + ((eq (car-safe last) 'cons) + (append (butlast form) (cdr last))) (t form))) form))) |