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