From e1ec1faff78edbb3158fa609c61622929f7b3e68 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 24 Dec 2018 17:05:13 +0000 Subject: Process events in order without cache --- scripts/toy.groovy | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/scripts/toy.groovy b/scripts/toy.groovy index 3d8b064..f5182aa 100644 --- a/scripts/toy.groovy +++ b/scripts/toy.groovy @@ -207,17 +207,13 @@ def removeEvent = { name -> saveEvents(events); }; def execEvents = { rt -> - def events = loadEvents(); - events - .findAll({ e -> e.value.time <= getTime() }) - .each({ e -> - def f = namedEvents[e.value.func]; - events.remove(e.key); - saveEvents(events); - if (f) { - f(e.key, e.value.arg, e.value.time, rt); - } - }) + for (def e = nextEvent(loadEvents()); e && e.event.time <= getTime(); e = nextEvent(loadEvents())) { + def f = namedEvents[e.event.func]; + removeEvent(e.name); + if (f) { + f(e.name, e.event.arg, e.event.time, rt); + } + } }; def sessionAborted = null; def gagText = { t, p -> -- cgit v1.2.3