summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/byte-opt.el
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2021-07-28 21:12:27 +0200
committerMattias EngdegÄrd <mattiase@acm.org>2021-07-30 09:54:29 +0200
commit566e29f78ccee4fcf0421576c0306860c8afae0f (patch)
treeaaedb56c599f5d80cb102b34e0fbc6522d74ba08 /lisp/emacs-lisp/byte-opt.el
parent5fb8b20fa35a931660d9d59afc9ca863dd33a123 (diff)
downloademacs-566e29f78ccee4fcf0421576c0306860c8afae0f.tar.gz
emacs-566e29f78ccee4fcf0421576c0306860c8afae0f.tar.bz2
emacs-566e29f78ccee4fcf0421576c0306860c8afae0f.zip
Single source optimiser entry point
Make the optimiser aware of lexical arguments. Otherwise we cannot know for sure whether a variable is lexical or dynamic during traversal. * lisp/emacs-lisp/byte-opt.el (byte-optimize-one-form): New optimiser entry point, replacing the recursive byte-optimize-form. * lisp/emacs-lisp/bytecomp.el (byte-optimize-one-form): Autoload. (byte-compile-keep-pending, byte-compile-top-level): Use byte-optimize-one-form.
Diffstat (limited to 'lisp/emacs-lisp/byte-opt.el')
-rw-r--r--lisp/emacs-lisp/byte-opt.el9
1 files changed, 8 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index ad9f827171a..4117533cda5 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -652,8 +652,15 @@ Same format as `byte-optimize--lexvars', with shared structure and contents.")
(byte-optimize-constant-args form)
form))))))
-(defun byte-optimize-form (form &optional for-effect)
+(defun byte-optimize-one-form (form &optional for-effect)
"The source-level pass of the optimizer."
+ ;; Make optimiser aware of lexical arguments.
+ (let ((byte-optimize--lexvars
+ (mapcar (lambda (v) (list (car v) t))
+ byte-compile--lexical-environment)))
+ (byte-optimize-form form for-effect)))
+
+(defun byte-optimize-form (form &optional for-effect)
(while
(progn
;; First, optimize all sub-forms of this one.