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

Better CPS conversion of multi-binding let

* lisp/emacs-lisp/generator.el (cps--transform-1):
Don't translate single-binding `let` into `let*` with an extra
temporary variable; it just adds two more useless states.
This commit is contained in:
Mattias Engdegård 2021-11-30 11:32:20 +01:00
parent f633116c09
commit 68c09c6b74

View file

@ -291,8 +291,15 @@ DYNAMIC-VAR bound to STATIC-VAR."
(cps--transform-1 `(progn ,@rest)
next-state)))
;; Process `let' in a helper function that transforms it into a
;; let* with temporaries.
(`(,(or 'let 'let*) () . ,body)
(cps--transform-1 `(progn ,@body) next-state))
(`(let (,binding) . ,body)
(cps--transform-1 `(let* (,binding) ,@body) next-state))
;; Transform multi-variable `let' into `let*':
;; (let ((v1 e1) ... (vN eN)) BODY)
;; -> (let* ((t1 e1) ... (tN eN) (v1 t1) (vN tN)) BODY)
(`(let ,bindings . ,body)
(let* ((bindings (cl-loop for binding in bindings
@ -315,9 +322,6 @@ DYNAMIC-VAR bound to STATIC-VAR."
;; Process `let*' binding: process one binding at a time. Flatten
;; lexical bindings.
(`(let* () . ,body)
(cps--transform-1 `(progn ,@body) next-state))
(`(let* (,binding . ,more-bindings) . ,body)
(let* ((var (if (symbolp binding) binding (car binding)))
(value-form (car (cdr-safe binding)))