mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-06 03:44:14 +00:00
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:
committed by
Patrick Kelley
parent
2abf3b717a
commit
c41e0bdbe3
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user