diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2021-12-11 22:11:08 +0100 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2021-12-11 22:16:55 +0100 |
commit | 8716f21d94bfda0072843e087833fedb38dcf13e (patch) | |
tree | 668849f67d7fa4b50d59b19ebaa6e52c546a9544 /lisp/emacs-lisp | |
parent | 36cd4f5d81c3c19e5719e25daa1a8e08c88cc1a7 (diff) | |
download | emacs-8716f21d94bfda0072843e087833fedb38dcf13e.tar.gz emacs-8716f21d94bfda0072843e087833fedb38dcf13e.tar.bz2 emacs-8716f21d94bfda0072843e087833fedb38dcf13e.zip |
Constant-propagate access to captured variables
* lisp/emacs-lisp/byte-opt.el (byte-optimize--substitutable-p):
Treat (internal-get-closed-var N) as constants for propagation
purposes, because that is effectively what such forms will be compiled
to. This allows for the elimination of some lexical variables.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases):
Add test case.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/byte-opt.el | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index f6db803b78e..2bdf1f55111 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -342,8 +342,12 @@ for speeding up processing.") (numberp expr) (stringp expr) (and (consp expr) - (memq (car expr) '(quote function)) - (symbolp (cadr expr))) + (or (and (memq (car expr) '(quote function)) + (symbolp (cadr expr))) + ;; (internal-get-closed-var N) can be considered constant for + ;; const-prop purposes. + (and (eq (car expr) 'internal-get-closed-var) + (integerp (cadr expr))))) (keywordp expr))) (defmacro byte-optimize--pcase (exp &rest cases) |