* lisp/emacs-lisp/thunk.el (thunk-delay): Fix memory leak
Get rid of references to the free variables of `body` once the thunk has been forced (bug#30626).
This commit is contained in:
parent
ffb7bbdf68
commit
f4d3253831
1 changed files with 9 additions and 10 deletions
|
@ -54,16 +54,15 @@
|
|||
"Delay the evaluation of BODY."
|
||||
(declare (debug t))
|
||||
(cl-assert lexical-binding)
|
||||
(let ((forced (make-symbol "forced"))
|
||||
(val (make-symbol "val")))
|
||||
`(let (,forced ,val)
|
||||
(lambda (&optional check)
|
||||
(if check
|
||||
,forced
|
||||
(unless ,forced
|
||||
(setf ,val (progn ,@body))
|
||||
(setf ,forced t))
|
||||
,val)))))
|
||||
`(let (forced
|
||||
(val (lambda () ,@body)))
|
||||
(lambda (&optional check)
|
||||
(if check
|
||||
forced
|
||||
(unless forced
|
||||
(setf val (funcall val))
|
||||
(setf forced t))
|
||||
val))))
|
||||
|
||||
(defun thunk-force (delayed)
|
||||
"Force the evaluation of DELAYED.
|
||||
|
|
Loading…
Add table
Reference in a new issue