Skip to content

Commit 91c0580

Browse files
authored
Avoid unnecessary JS call in _emscripten_next_timer. NFC (#26695)
1 parent 0f64d2a commit 91c0580

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

system/lib/libc/musl/src/signal/setitimer.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ double _emscripten_next_timer()
9090
next_timer = fmin(current_timeout_ms[which], next_timer);
9191
}
9292
}
93-
return next_timer - emscripten_get_now();
93+
// Avoid calling emscripten_get_now() unless we need to here.
94+
if (next_timer != INFINITY) {
95+
next_timer -= emscripten_get_now();
96+
}
97+
return next_timer;
9498
}
9599
#endif
96100

test/codesize/test_codesize_hello_dylink_all.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"a.out.js": 244278,
3-
"a.out.nodebug.wasm": 577639,
4-
"total": 821917,
3+
"a.out.nodebug.wasm": 577664,
4+
"total": 821942,
55
"sent": [
66
"IMG_Init",
77
"IMG_Load",

0 commit comments

Comments
 (0)