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.
This commit is contained in:
GrundleTrundle
2015-02-21 14:57:07 -05:00
committed by Patrick Kelley
parent 2abf3b717a
commit c41e0bdbe3

View File

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