emacs-diffs
[Top][All Lists]
Advanced

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

master a1d90e48bb0 1/2: Small unwind-protect optimisation improvement


From: Mattias Engdegård
Subject: master a1d90e48bb0 1/2: Small unwind-protect optimisation improvement
Date: Thu, 2 Mar 2023 09:52:52 -0500 (EST)

branch: master
commit a1d90e48bb0076e68592d6a6880c28b52e61d219
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    Small unwind-protect optimisation improvement
    
    * lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker):
    Use the current for-effect mode when optimising the body form,
    instead of always optimising it for value.
---
 lisp/emacs-lisp/byte-opt.el | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 0ae4c452c73..3c7aeb89525 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -439,13 +439,12 @@ for speeding up processing.")
                               (byte-optimize-body (cdr clause) for-effect))))
                     clauses)))
 
-      ;; `unwind-protect' is a special form which here takes the shape
-      ;; (unwind-protect EXPR :fun-body UNWIND-FUN).
-      ;; We can treat it as if it were a plain function at this point,
-      ;; although there are specific optimizations possible.
-      ;; In particular, the return value of UNWIND-FUN is never used
-      ;; so its body should really be compiled for-effect, but we
-      ;; don't do that right now.
+      (`(unwind-protect ,protected-expr :fun-body ,unwind-fun)
+       ;; FIXME: The return value of UNWIND-FUN is never used so we
+       ;; could potentially optimise it for-effect, but we don't do
+       ;; that right no.
+       `(,fn ,(byte-optimize-form protected-expr for-effect)
+             :fun-body ,(byte-optimize-form unwind-fun)))
 
       (`(catch ,tag . ,exps)
        `(,fn ,(byte-optimize-form tag nil)



reply via email to

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