From: Mattias EngdegÄrd Date: Thu, 26 Dec 2019 16:50:19 +0000 (+0100) Subject: Optimise 'while' bodies for effect X-Git-Tag: emacs-28.0.90~7934 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1ba5b64dd1f0c0b22f3945ddc8b236fd565ebee8;p=emacs.git 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. --- 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))