1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-10 00:00:39 -08:00

byte-opt.el: More concise expression

* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker):
Refactor `setq` clause.
This commit is contained in:
Mattias Engdegård 2021-02-12 19:41:07 +01:00
parent ea29908c18
commit 5a11e9185c

View file

@ -593,16 +593,15 @@ Same format as `byte-optimize--lexvars', with shared structure and contents.")
(lexvar (assq var byte-optimize--lexvars))
(value (byte-optimize-form expr nil)))
(when lexvar
;; If it's bound outside conditional, invalidate.
(if (assq var byte-optimize--vars-outside-condition)
;; We are in conditional code and the variable was
;; bound outside: cancel substitutions.
(setcdr (cdr lexvar) nil)
;; Set a new value (if substitutable).
(setcdr (cdr lexvar)
(and (byte-optimize--substitutable-p value)
(list value))))
(setcar (cdr lexvar) t)) ; Mark variable to be kept.
;; Set a new value or inhibit further substitution.
(setcdr (cdr lexvar)
(and
;; Inhibit if bound outside conditional code.
(not (assq var byte-optimize--vars-outside-condition))
;; The new value must be substitutable.
(byte-optimize--substitutable-p value)
(list value)))
(setcar (cdr lexvar) t)) ; Mark variable to be kept.
(push var var-expr-list)
(push value var-expr-list))
(setq args (cddr args)))