]> git.eshelyaron.com Git - emacs.git/commitdiff
Optimise 'while' bodies for effect
authorMattias Engdegård <mattiase@acm.org>
Thu, 26 Dec 2019 16:50:19 +0000 (17:50 +0100)
committerMattias Engdegård <mattiase@acm.org>
Thu, 26 Dec 2019 18:41:21 +0000 (19:41 +0100)
* 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.

lisp/emacs-lisp/byte-opt.el

index 22fea1b8da9d41d05ad599b457267779dc882e61..07fd548dec2ff3862df744ed6d18c6cb1ae52bff 100644 (file)
                                                  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))