summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/byte-opt.el
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2019-12-26 17:50:19 +0100
committerMattias EngdegÄrd <mattiase@acm.org>2019-12-26 19:41:21 +0100
commit1ba5b64dd1f0c0b22f3945ddc8b236fd565ebee8 (patch)
tree26e726abedef12c46fa03a60811830a3c74d15f8 /lisp/emacs-lisp/byte-opt.el
parentaf085ef40b961ca3466e8b2dfb7f722573e5a4cc (diff)
downloademacs-1ba5b64dd1f0c0b22f3945ddc8b236fd565ebee8.tar.gz
emacs-1ba5b64dd1f0c0b22f3945ddc8b236fd565ebee8.tar.bz2
emacs-1ba5b64dd1f0c0b22f3945ddc8b236fd565ebee8.zip
Optimise 'while' bodies for effect
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): Treat all expressions in the body of 'while' as for-effect, since their values are discarded. This also finds some errors.
Diffstat (limited to 'lisp/emacs-lisp/byte-opt.el')
-rw-r--r--lisp/emacs-lisp/byte-opt.el7
1 files changed, 7 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 22fea1b8da9..07fd548dec2 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -480,6 +480,13 @@
backwards)))))
(cons fn (mapcar 'byte-optimize-form (cdr form)))))
+ ((eq fn 'while)
+ (unless (consp (cdr form))
+ (byte-compile-warn "too few arguments for `while'"))
+ (cons fn
+ (cons (byte-optimize-form (cadr form) nil)
+ (byte-optimize-body (cddr form) t))))
+
((eq fn 'interactive)
(byte-compile-warn "misplaced interactive spec: `%s'"
(prin1-to-string form))