mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 14:30:50 -08:00
Better internal-make-closure optimisation
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): Optimise closed-over values in closure creation like any other, which can lead to stack variables being eliminated.
This commit is contained in:
parent
5d3d84066f
commit
6058b4559d
1 changed files with 4 additions and 10 deletions
|
|
@ -447,16 +447,10 @@ for speeding up processing.")
|
||||||
. ,(byte-optimize-body exps for-effect)))
|
. ,(byte-optimize-body exps for-effect)))
|
||||||
|
|
||||||
;; Needed as long as we run byte-optimize-form after cconv.
|
;; Needed as long as we run byte-optimize-form after cconv.
|
||||||
(`(internal-make-closure . ,_)
|
(`(internal-make-closure ,vars ,env . ,rest)
|
||||||
(and (not for-effect)
|
(if for-effect
|
||||||
(progn
|
`(progn ,@(byte-optimize-body env t))
|
||||||
;; Look up free vars and mark them to be kept, so that they
|
`(,fn ,vars ,(mapcar #'byte-optimize-form env) . ,rest)))
|
||||||
;; won't be optimized away.
|
|
||||||
(dolist (var (caddr form))
|
|
||||||
(let ((lexvar (assq var byte-optimize--lexvars)))
|
|
||||||
(when lexvar
|
|
||||||
(setcar (cdr lexvar) t))))
|
|
||||||
form)))
|
|
||||||
|
|
||||||
(`((lambda . ,_) . ,_)
|
(`((lambda . ,_) . ,_)
|
||||||
(let ((newform (macroexp--unfold-lambda form)))
|
(let ((newform (macroexp--unfold-lambda form)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue