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) committed 2021-06-22 18:17:11 +03:00
1 parent 76b1ac57a4
commit 0427fe97e1
1 file changed
+1 -1
+1 -1
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;
}