Skip to content

Commit

Permalink
Merge pull request #337 from alexandergall/perf-tweaks-2
Browse files Browse the repository at this point in the history
Performance tweaks in core/timer.lua
  • Loading branch information
lukego committed Dec 10, 2014
2 parents 7e311e4 + 86d818d commit 00342a2
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/core/timer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ end

-- Run all timers that have expired.
function run ()
if ticks then run_to_time(C.get_time_ns()) end
if ticks then run_to_time(tonumber(C.get_time_ns())) end
end

-- Run all timers up to the given new time.
function run_to_time (ns)
local function call_timers (l)
for i=1,#l do
local timer = l[i]
if debug then
print(string.format("running timer %s at tick %s", timer.name, ticks))
end
timer.fn(timer)
if timer.repeating then activate(timer) end
local function call_timers (l)
for i=1,#l do
local timer = l[i]
if debug then
print(string.format("running timer %s at tick %s", timer.name, ticks))
end
timer.fn(timer)
if timer.repeating then activate(timer) end
end
end
function run_to_time (ns)
local new_ticks = math.floor(tonumber(ns) / ns_per_tick)
for tick = ticks, new_ticks do
ticks = tick
Expand Down

0 comments on commit 00342a2

Please sign in to comment.