js: idle-observers: minor performance improvement

The idle-observers block has at least 3 function calls, and it was
entered every time the script went into idle, however, we can save these
calls by checking first that there are indeed such observers.
This commit is contained in:
Avi Halachmi (:avih) 2021-06-22 18:17:09 +03:00
parent 76b1ac57a4
commit 0427fe97e1
1 changed files with 1 additions and 1 deletions

View File

@ -751,7 +751,7 @@ g.mp_event_loop = function mp_event_loop() {
wait = 0; // poll the next one
} else {
wait = process_timers() / 1000;
if (wait != 0) {
if (wait != 0 && iobservers.length) {
notify_idle_observers(); // can add timers -> recalculate wait
wait = peek_timers_wait() / 1000;
}