aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias EngdegÄrd2019-12-26 17:50:19 +0100
committerMattias EngdegÄrd2019-12-26 19:41:21 +0100
commit1ba5b64dd1f0c0b22f3945ddc8b236fd565ebee8 (patch)
tree26e726abedef12c46fa03a60811830a3c74d15f8
parentaf085ef40b961ca3466e8b2dfb7f722573e5a4cc (diff)
downloademacs-1ba5b64dd1f0c0b22f3945ddc8b236fd565ebee8.tar.gz
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.
-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 @@
480 backwards))))) 480 backwards)))))
481 (cons fn (mapcar 'byte-optimize-form (cdr form))))) 481 (cons fn (mapcar 'byte-optimize-form (cdr form)))))
482 482
483 ((eq fn 'while)
484 (unless (consp (cdr form))
485 (byte-compile-warn "too few arguments for `while'"))
486 (cons fn
487 (cons (byte-optimize-form (cadr form) nil)
488 (byte-optimize-body (cddr form) t))))
489
483 ((eq fn 'interactive) 490 ((eq fn 'interactive)
484 (byte-compile-warn "misplaced interactive spec: `%s'" 491 (byte-compile-warn "misplaced interactive spec: `%s'"
485 (prin1-to-string form)) 492 (prin1-to-string form))