From a7fcdd2b1bc8c8fe1ffe147f17207223b7d6c6e4 Mon Sep 17 00:00:00 2001 From: kikito Date: Sun, 28 Oct 2012 17:16:32 +0100 Subject: [PATCH] refactor entry update method --- cron.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cron.lua b/cron.lua index 0cc7582..290c1a5 100644 --- a/cron.lua +++ b/cron.lua @@ -46,7 +46,7 @@ local function updateTimedEntry(self, dt) -- returns true if expired self.running = self.running + dt if self.running >= self.time then self.callback(unpack(self.args)) - return true + entries[self] = nil end end @@ -84,9 +84,7 @@ end function cron.update(dt) assert(type(dt) == "number" and dt >= 0, "dt must be a non-negative number") - for id, entry in pairs(entries) do - if entry:update(dt) then entries[id] = nil end - end + for _, entry in pairs(entries) do entry:update(dt) end end return cron