Skip to content

Commit 3106f67

Browse files
authored
Remove unnecessary calls to polyfillSetImmediate. NFC (#20379)
This function exists purely for its postset, there is no need to actually call it. Also, use arrow functions in most places within this file.
1 parent 3562824 commit 3106f67

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/library_eventloop.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,10 @@ LibraryJSEventLoop = {
8282

8383
emscripten_set_immediate__deps: ['$polyfillSetImmediate', '$callUserCallback'],
8484
emscripten_set_immediate: (cb, userData) => {
85-
polyfillSetImmediate();
8685
{{{ runtimeKeepalivePush(); }}}
87-
return emSetImmediate(function() {
86+
return emSetImmediate(() => {
8887
{{{ runtimeKeepalivePop(); }}}
89-
callUserCallback(function() {
90-
{{{ makeDynCall('vp', 'cb') }}}(userData);
91-
});
88+
callUserCallback(() => {{{ makeDynCall('vp', 'cb') }}}(userData));
9289
});
9390
},
9491

@@ -100,9 +97,8 @@ LibraryJSEventLoop = {
10097

10198
emscripten_set_immediate_loop__deps: ['$polyfillSetImmediate', '$callUserCallback'],
10299
emscripten_set_immediate_loop: (cb, userData) => {
103-
polyfillSetImmediate();
104100
function tick() {
105-
callUserCallback(function() {
101+
callUserCallback(() => {
106102
if ({{{ makeDynCall('ip', 'cb') }}}(userData)) {
107103
emSetImmediate(tick);
108104
} else {
@@ -126,7 +122,7 @@ LibraryJSEventLoop = {
126122
var t = _emscripten_get_now();
127123
var n = t + msecs;
128124
{{{ runtimeKeepalivePop() }}}
129-
callUserCallback(function() {
125+
callUserCallback(() => {
130126
if ({{{ makeDynCall('idp', 'cb') }}}(t, userData)) {
131127
// Save a little bit of code space: modern browsers should treat
132128
// negative setTimeout as timeout of 0
@@ -143,10 +139,8 @@ LibraryJSEventLoop = {
143139
emscripten_set_interval__deps: ['$callUserCallback'],
144140
emscripten_set_interval: (cb, msecs, userData) => {
145141
{{{ runtimeKeepalivePush() }}}
146-
return setInterval(function() {
147-
callUserCallback(function() {
148-
{{{ makeDynCall('vp', 'cb') }}}(userData)
149-
});
142+
return setInterval(() => {
143+
callUserCallback(() => {{{ makeDynCall('vp', 'cb') }}}(userData));
150144
}, msecs);
151145
},
152146

0 commit comments

Comments
 (0)