96818717e72d

Don't render `previous-var` in `timing` unless needed
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 15 Oct 2016 13:12:30 +0000
parents f1e161fed238
children ee0d61f41802
branches/tags (none)
files losh.lisp

Changes

--- a/losh.lisp	Tue Sep 27 12:13:54 2016 +0000
+++ b/losh.lisp	Sat Oct 15 13:12:30 2016 +0000
@@ -762,17 +762,17 @@
   (let ((timing-function (ecase time-type
                            ((real-time) #'get-internal-real-time)
                            ((run-time) #'get-internal-run-time)))
-        (since (or since-var (when (null per-var)
-                               iterate::*result-var*))))
+        (since-var (or since-var (when (null per-var)
+                                   iterate::*result-var*))))
     (with-gensyms (start-time current-time previous-time)
       `(progn
         (with ,start-time = (funcall ,timing-function))
         (for ,current-time = (funcall ,timing-function))
-        (for ,previous-time :previous ,current-time :initially ,start-time)
-        ,(when since
-           `(for ,since = (- ,current-time ,start-time)))
-        ,(when per-var
-           `(for ,per-var = (- ,current-time ,previous-time)))))))
+        ,@(when since-var
+            `((for ,since-var = (- ,current-time ,start-time))))
+        ,@(when per-var
+            `((for ,previous-time :previous ,current-time :initially ,start-time)
+              (for ,per-var = (- ,current-time ,previous-time))))))))
 
 
 (defmacro-driver (FOR var IN-LISTS lists)
@@ -1364,8 +1364,6 @@
                            (list key-width key val)))))))
 
 
-
-
 ;;;; Weightlists
 (defstruct (weightlist (:constructor %make-weightlist))
   weights sums items total)