Skip to content

Commit 546353b

Browse files
authored
Remove trivial lambda function wrappers. NFC (#20972)
I found all these using `git grep -P "(\(.*\)) => \w*(\\1)"`.
1 parent 5e3e1e0 commit 546353b

28 files changed

+32
-36
lines changed

src/library.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ addToLibrary({
4848
#if SAFE_HEAP
4949
// Trivial wrappers around runtime functions that make these symbols available
5050
// to native code.
51-
segfault: () => segfault(),
52-
alignfault: () => alignfault(),
51+
segfault: '=segfault',
52+
alignfault: '=alignfault',
5353
#endif
5454

5555
// ==========================================================================
@@ -851,7 +851,7 @@ addToLibrary({
851851

852852
return getWeekBasedYear(date).toString().substring(2);
853853
},
854-
'%G': (date) => getWeekBasedYear(date),
854+
'%G': getWeekBasedYear,
855855
'%H': (date) => leadingNulls(date.tm_hour, 2),
856856
'%I': (date) => {
857857
var twelveHour = date.tm_hour;
@@ -3032,7 +3032,7 @@ addToLibrary({
30323032
// Converts a JS string to an integer base-10, with signaling error
30333033
// handling (throws a JS exception on error). E.g. jstoi_s("123abc")
30343034
// throws an exception.
3035-
$jstoi_s: (str) => Number(str),
3035+
$jstoi_s: 'Number',
30363036

30373037
#if LINK_AS_CXX
30383038
// libunwind

src/library_async.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ addToLibrary({
407407
_free(Asyncify.currData);
408408
Asyncify.currData = null;
409409
// Call all sleep callbacks now that the sleep-resume is all done.
410-
Asyncify.sleepCallbacks.forEach((func) => callUserCallback(func));
410+
Asyncify.sleepCallbacks.forEach(callUserCallback);
411411
} else {
412412
abort(`invalid state: ${Asyncify.state}`);
413413
}
@@ -446,9 +446,7 @@ addToLibrary({
446446
}
447447
},
448448
handleSleep(startAsync) {
449-
return Asyncify.handleAsync(() => (
450-
new Promise((wakeUp) => startAsync(wakeUp))
451-
));
449+
return Asyncify.handleAsync(() => new Promise(startAsync));
452450
},
453451
makeAsyncFunction(original) {
454452
#if ASYNCIFY_DEBUG

src/library_dylink.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ var LibraryDylink = {
10061006
var libFile = locateFile(libName);
10071007
if (flags.loadAsync) {
10081008
return new Promise(function(resolve, reject) {
1009-
asyncLoad(libFile, (data) => resolve(data), reject);
1009+
asyncLoad(libFile, resolve, reject);
10101010
});
10111011
}
10121012

src/library_eventloop.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ LibraryJSEventLoop = {
114114
emscripten_set_timeout: (cb, msecs, userData) =>
115115
safeSetTimeout(() => {{{ makeDynCall('vp', 'cb') }}}(userData), msecs),
116116

117-
emscripten_clear_timeout: (id) => clearTimeout(id),
117+
emscripten_clear_timeout: 'clearTimeout',
118118

119119
emscripten_set_timeout_loop__deps: ['$callUserCallback', 'emscripten_get_now'],
120120
emscripten_set_timeout_loop: (cb, msecs, userData) => {

src/library_fs_shared.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ addToLibrary({
7676
}
7777
addRunDependency(dep);
7878
if (typeof url == 'string') {
79-
asyncLoad(url, (byteArray) => processData(byteArray), onerror);
79+
asyncLoad(url, processData, onerror);
8080
} else {
8181
processData(url);
8282
}

src/library_html5.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,7 @@ var LibraryHTML5 = {
364364
#endif
365365
},
366366
#else
367-
$findCanvasEventTarget__deps: ['$findEventTarget'],
368-
$findCanvasEventTarget: (target) => findEventTarget(target),
367+
$findCanvasEventTarget: '$findEventTarget',
369368
#endif
370369

371370
#else

src/library_pthread.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ var LibraryPThread = {
12891289
_emscripten_notify_mailbox_postmessage__deps: ['$checkMailbox'],
12901290
_emscripten_notify_mailbox_postmessage: (targetThreadId, currThreadId, mainThreadId) => {
12911291
if (targetThreadId == currThreadId) {
1292-
setTimeout(() => checkMailbox());
1292+
setTimeout(checkMailbox);
12931293
} else if (ENVIRONMENT_IS_PTHREAD) {
12941294
postMessage({'targetThread' : targetThreadId, 'cmd' : 'checkMailbox'});
12951295
} else {

src/library_sdl.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,8 +1417,7 @@ var LibrarySDL = {
14171417
// bits-per-pixel of the closest available mode with the given width, height and requested surface flags
14181418
SDL_VideoModeOK: (width, height, depth, flags) => depth, // all modes are ok.
14191419

1420-
SDL_AudioDriverName__deps: ['SDL_VideoDriverName'],
1421-
SDL_AudioDriverName: (buf, max_size) => _SDL_VideoDriverName(buf, max_size),
1420+
SDL_AudioDriverName: 'SDL_VideoDriverName',
14221421

14231422
SDL_VideoDriverName__proxy: 'sync',
14241423
SDL_VideoDriverName: (buf, max_size) => {

src/library_webgl2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var LibraryWebGL2 = {
2424
}
2525
switch (name) {
2626
case 0x1F03 /* GL_EXTENSIONS */:
27-
var exts = GL.getExtensions().map((e) => stringToNewUTF8(e));
27+
var exts = GL.getExtensions().map(stringToNewUTF8);
2828
stringiCache = GL.stringiCache[name] = exts;
2929
if (index < 0 || index >= stringiCache.length) {
3030
GL.recordError(0x501/*GL_INVALID_VALUE*/);

src/proxyWorker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ function messageResender() {
380380
if (calledMain) {
381381
assert(messageBuffer && messageBuffer.length > 0);
382382
messageResenderTimeout = null;
383-
messageBuffer.forEach((message) => onmessage(message));
383+
messageBuffer.forEach(onmessage);
384384
messageBuffer = null;
385385
} else {
386386
messageResenderTimeout = setTimeout(messageResender, 100);

0 commit comments

Comments
 (0)