emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master f4d3253: * lisp/emacs-lisp/thunk.el (thunk-delay):


From: Stefan Monnier
Subject: [Emacs-diffs] master f4d3253: * lisp/emacs-lisp/thunk.el (thunk-delay): Fix memory leak
Date: Tue, 4 Jun 2019 12:55:59 -0400 (EDT)

branch: master
commit f4d32538317c2cc6e8e9041d07d84b1e812e4e19
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * 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).
---
 lisp/emacs-lisp/thunk.el | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/lisp/emacs-lisp/thunk.el b/lisp/emacs-lisp/thunk.el
index e1370c4..8d28570 100644
--- a/lisp/emacs-lisp/thunk.el
+++ b/lisp/emacs-lisp/thunk.el
@@ -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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]