[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 1438574dd73 1/4: Don't inline funcall to literal lambda form
From: |
Mattias Engdegård |
Subject: |
master 1438574dd73 1/4: Don't inline funcall to literal lambda form |
Date: |
Fri, 5 May 2023 16:01:33 -0400 (EDT) |
branch: master
commit 1438574dd73a097293f8cfe356c3459cec6ee005
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
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.
---
lisp/emacs-lisp/byte-opt.el | 11 +++++++----
1 file 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)))