Rollback loop change (references #2)

Tests didn't pass. Further examination revealed that, even if the Lua
standard seems to allow for eliminating table keys while parsing it in
a loop, in reality those values remained in the table.
This commit is contained in:
kikito 2012-10-27 18:31:21 +02:00
parent 2a1ad28c94
commit 6e72b85232

View File

@ -79,8 +79,12 @@ end
function cron.update(dt)
assert(type(dt) == "number" and dt >= 0, "dt must be a non-negative number")
local expired = {}
for id, entry in pairs(entries) do
if entry:update(dt) then entry[id] = nil end
if entry:update(dt) then expired[id] = true end
end
for id,_ in pairs(expired) do
entries[id] = nil
end
end