1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-12 09:28:24 +00:00

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.
This commit is contained in:
Mattias Engdegård 2021-09-06 14:41:26 +02:00
parent bba48d6ee5
commit c4724add00

View File

@ -727,8 +727,12 @@ Same format as `byte-optimize--lexvars', with shared structure and contents.")
(while rest (while rest
(setq fe (or all-for-effect (cdr rest))) (setq fe (or all-for-effect (cdr rest)))
(setq new (and (car rest) (byte-optimize-form (car rest) fe))) (setq new (and (car rest) (byte-optimize-form (car rest) fe)))
(if (or new (not fe)) (when (and (consp new) (eq (car new) 'progn))
(setq result (cons new result))) ;; 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))) (setq rest (cdr rest)))
(nreverse result))) (nreverse result)))