diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2021-11-30 11:32:20 +0100 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2021-11-30 13:03:49 +0100 |
commit | 68c09c6b741be5005b90152c59e781cb0f80704d (patch) | |
tree | 589501246dac92506601cc20439b76611486e8d8 /lisp/emacs-lisp | |
parent | f633116c09d0ca8be1bdd332283108b03dfcf0c8 (diff) | |
download | emacs-68c09c6b741be5005b90152c59e781cb0f80704d.tar.gz emacs-68c09c6b741be5005b90152c59e781cb0f80704d.tar.bz2 emacs-68c09c6b741be5005b90152c59e781cb0f80704d.zip |
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.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/generator.el | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el index 2075ac472d1..4e286ed7ec4 100644 --- a/lisp/emacs-lisp/generator.el +++ b/lisp/emacs-lisp/generator.el @@ -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))) |