summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorGrundleTrundle <gtrundle@sdf.org>2015-02-21 14:57:07 -0500
committerPatrick Kelley <Pat.Kelley@gmail.com>2015-02-21 15:18:39 -0500
commitc41e0bdbe32f1f08951aef6e746265775b1ecba8 (patch)
tree68c7f7844976c2f1d90b5c00100a8dcb1ab5cbc6
parent2abf3b717abfd623c89893e14037c34b73ef99f1 (diff)
downloadNim-c41e0bdbe32f1f08951aef6e746265775b1ecba8.tar.gz
Changed nimprof.hook() to handle uninitialized t0
It's unlikely, but possible for the conversion to nanoseconds
to overflow if QueryPerformanceCounter() returns a
large enough timestamp.  This change avoids that, at the
cost of always taking a sample the first time through
when t0 == 0.
-rw-r--r--lib/pure/nimprof.nim2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/pure/nimprof.nim b/lib/pure/nimprof.nim
index 3598cdd3a..cce2a20ae 100644
--- a/lib/pure/nimprof.nim
+++ b/lib/pure/nimprof.nim
@@ -132,7 +132,7 @@ else:
   proc hook(st: TStackTrace) {.nimcall.} =
     if interval == 0:
       hookAux(st, 1)
-    elif getTicks() - t0 > interval:
+    elif int64(t0) == 0 or getTicks() - t0 > interval:
       hookAux(st, 1)
       t0 = getTicks()