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.
This commit is contained in:
Mattias Engdegård 2019-12-26 17:50:19 +01:00
parent af085ef40b
commit 1ba5b64dd1

View file

@ -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))