From badef58d0ad97401540ea961f34841c2911683ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= Date: Wed, 11 Feb 2026 18:42:46 +0100 Subject: [PATCH] Better 'prog1' optimisation * lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): Always evaporate 'prog1' when the tail is effect-free, even when the value expression isn't. --- lisp/emacs-lisp/byte-opt.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index c5458c1ba69..1aecae5ac7d 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -345,9 +345,9 @@ There can be multiple entries for the same NAME if it has several aliases.") (let ((exp-opt (byte-optimize-form exp for-effect))) (if exps (let ((exps-opt (byte-optimize-body exps t))) - (if (macroexp-const-p exp-opt) - `(progn ,@exps-opt ,exp-opt) - `(,fn ,exp-opt ,@exps-opt))) + (cond ((null exps-opt) exp-opt) + ((macroexp-const-p exp-opt) `(progn ,@exps-opt ,exp-opt)) + (t `(,fn ,exp-opt ,@exps-opt)))) exp-opt))) (`(,(or `save-excursion `save-restriction `save-current-buffer) . ,exps)