1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

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.
This commit is contained in:
Mattias Engdegård 2023-03-01 19:37:52 +01:00
parent 8106cb50f5
commit a1d90e48bb

View file

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