diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2021-09-06 14:41:26 +0200 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2021-09-06 16:47:13 +0200 |
commit | c4724add006e62b81f847937db56335a81bdcc74 (patch) | |
tree | ddaf499a65e61057ee14f57a7f3fda6c6f5b7d71 /lisp/emacs-lisp/byte-opt.el | |
parent | bba48d6ee5d90f326c70cbe8af19dfe6b00651ba (diff) | |
download | emacs-c4724add006e62b81f847937db56335a81bdcc74.tar.gz emacs-c4724add006e62b81f847937db56335a81bdcc74.tar.bz2 emacs-c4724add006e62b81f847937db56335a81bdcc74.zip |
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.
Diffstat (limited to 'lisp/emacs-lisp/byte-opt.el')
-rw-r--r-- | lisp/emacs-lisp/byte-opt.el | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index 23c5a566cea..ff512cca36f 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))) |