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.
This commit is contained in:
parent
0e8d8a7228
commit
1438574dd7
1 changed files with 7 additions and 4 deletions
|
@ -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)))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue