mirror of
https://github.com/vrld/hump.git
synced 2024-11-23 12:24:19 +00:00
shorten code, add comment
This commit is contained in:
parent
dde34f98a9
commit
e33ffbe855
10
timer.lua
10
timer.lua
@ -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>,
|
||||||
|
Loading…
Reference in New Issue
Block a user