summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2023-05-04 17:28:08 +0200
committerMattias EngdegÄrd <mattiase@acm.org>2023-05-05 22:00:27 +0200
commit1438574dd73a097293f8cfe356c3459cec6ee005 (patch)
tree6e3ee44020a988bfdcb392a18f69fa985a140b87 /lisp/emacs-lisp
parent0e8d8a72284f6b3aaa1bbce73d41c7d84bbc4d3c (diff)
downloademacs-1438574dd73a097293f8cfe356c3459cec6ee005.tar.gz
emacs-1438574dd73a097293f8cfe356c3459cec6ee005.tar.bz2
emacs-1438574dd73a097293f8cfe356c3459cec6ee005.zip
Don't inline funcall to literal lambda form
* lisp/emacs-lisp/byte-opt.el (byte-optimize-funcall): Don't convert (funcall '(lambda ...) ...) -> ((lambda ...) ...) because that would inline what is essentially an `eval` of a function using dynamic binding rules into lexbound code.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/byte-opt.el11
1 files changed, 7 insertions, 4 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 0f7a3cb2665..d859706c180 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -1420,10 +1420,13 @@ See Info node `(elisp) Integer Basics'."
(defun byte-optimize-funcall (form)
- ;; (funcall (lambda ...) ...) ==> ((lambda ...) ...)
- ;; (funcall foo ...) ==> (foo ...)
- (let ((fn (nth 1 form)))
- (if (memq (car-safe fn) '(quote function))
+ ;; (funcall #'(lambda ...) ...) -> ((lambda ...) ...)
+ ;; (funcall #'SYM ...) -> (SYM ...)
+ ;; (funcall 'SYM ...) -> (SYM ...)
+ (let* ((fn (nth 1 form))
+ (head (car-safe fn)))
+ (if (or (eq head 'function)
+ (and (eq head 'quote) (symbolp (nth 1 fn))))
(cons (nth 1 fn) (cdr (cdr form)))
form)))