emacs-diffs
[Top][All Lists]
Advanced

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

master c4724ad 3/3: Normalise nested `progn` forms in byte-code optimise


From: Mattias Engdegård
Subject: master c4724ad 3/3: Normalise nested `progn` forms in byte-code optimiser
Date: Mon, 6 Sep 2021 10:48:38 -0400 (EDT)

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

    Normalise nested `progn` forms in byte-code optimiser
    
    * lisp/emacs-lisp/byte-opt.el (byte-optimize-body): Flatten body.
    This simplifies the source tree and reduces the number of different
    cases that other optimisations need to take into account.
---
 lisp/emacs-lisp/byte-opt.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 23c5a56..ff512cc 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -727,8 +727,12 @@ Same format as `byte-optimize--lexvars', with shared 
structure and contents.")
     (while rest
       (setq fe (or all-for-effect (cdr rest)))
       (setq new (and (car rest) (byte-optimize-form (car rest) fe)))
-      (if (or new (not fe))
-         (setq result (cons new result)))
+      (when (and (consp new) (eq (car new) 'progn))
+        ;; Flatten `progn' form into the body.
+        (setq result (append (reverse (cdr new)) result))
+        (setq new (pop result)))
+      (when (or new (not fe))
+       (setq result (cons new result)))
       (setq rest (cdr rest)))
     (nreverse result)))
 



reply via email to

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