shorten code, add comment

This commit is contained in:
Matthias Richter 2018-04-08 13:40:57 +02:00
parent dde34f98a9
commit e33ffbe855

View File

@ -32,14 +32,14 @@ local function _nothing_() end
function Timer:update(dt) function Timer:update(dt)
local to_remove = {} local to_remove = {}
local handles = {} -- timers may create new timers, which leads to undefined behavior
local len = 0 -- in pairs() - so we need to put them in a different table first
local to_update = {}
for handle in pairs(self.functions) do for handle in pairs(self.functions) do
len = len + 1 to_update[handle] = handle
handles[len] = handle
end end
for _, handle in ipairs(handles) do for handle in pairs(to_update) do
-- handle: { -- handle: {
-- time = <number>, -- time = <number>,
-- after = <function>, -- after = <function>,