From aebc110e98dd51749fe5c2dcd8b78344d2c6216b Mon Sep 17 00:00:00 2001 From: Gabor Greif Date: Fri, 22 Nov 2024 18:27:45 -0300 Subject: [PATCH] perf: use less cycles in `@timer_helper` (#4777) Since the observation of a `null` in the expiration array means there will be no more found, it is pointless to stay in the loop. I expect 1 expiration per callback in the frequent case. --- src/prelude/internals.mo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/prelude/internals.mo b/src/prelude/internals.mo index b98be29c768..713b7544ddb 100644 --- a/src/prelude/internals.mo +++ b/src/prelude/internals.mo @@ -614,8 +614,8 @@ func @timer_helper() : async () { for (o in thunks.vals()) { switch o { - case (?thunk) { ignore thunk() }; - case _ { } + case (?thunk) ignore thunk(); + case _ return } } };