diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-06-14 16:21:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-14 16:21:06 +0200 |
commit | 5ef225853c0f81ba0a7d1ce888ab3b2d283eae0a (patch) | |
tree | 169c5e4f2f428bf3782351c5b9563febaa100dfd /ext/web/02_timers.js | |
parent | 691ef2cc6a1144d17d6ffbc7f4ed88ba424ec3c0 (diff) |
perf: don't run microtask checkpoint if macrotask callback did no work (#19492)
Most of the time there's no firing timers, nor pending promise
rejections, so it's wasteful to run microtask checkpoint
additionally twice on each tick of the event loop.
Closes https://github.com/denoland/deno/issues/18871
Ref https://github.com/denoland/deno/issues/19451
Diffstat (limited to 'ext/web/02_timers.js')
-rw-r--r-- | ext/web/02_timers.js | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/ext/web/02_timers.js b/ext/web/02_timers.js index 19ebfaa0e..27e2e953d 100644 --- a/ext/web/02_timers.js +++ b/ext/web/02_timers.js @@ -54,8 +54,10 @@ const timerTasks = []; let timerNestingLevel = 0; function handleTimerMacrotask() { + // We have no work to do, tell the runtime that we don't + // need to perform microtask checkpoint. if (timerTasks.length === 0) { - return true; + return undefined; } const task = ArrayPrototypeShift(timerTasks); |