Skip to content

Commit

Permalink
Remove trivial lambda function wrappers. NFC (emscripten-core#20972)
Browse files Browse the repository at this point in the history
I found all these using `git grep -P "(\(.*\)) => \w*(\\1)"`.
  • Loading branch information
sbc100 authored Jan 3, 2024
1 parent 5e3e1e0 commit 546353b
Show file tree
Hide file tree
Showing 28 changed files with 32 additions and 36 deletions.
8 changes: 4 additions & 4 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ addToLibrary({
#if SAFE_HEAP
// Trivial wrappers around runtime functions that make these symbols available
// to native code.
segfault: () => segfault(),
alignfault: () => alignfault(),
segfault: '=segfault',
alignfault: '=alignfault',
#endif

// ==========================================================================
Expand Down Expand Up @@ -851,7 +851,7 @@ addToLibrary({
return getWeekBasedYear(date).toString().substring(2);
},
'%G': (date) => getWeekBasedYear(date),
'%G': getWeekBasedYear,
'%H': (date) => leadingNulls(date.tm_hour, 2),
'%I': (date) => {
var twelveHour = date.tm_hour;
Expand Down Expand Up @@ -3032,7 +3032,7 @@ addToLibrary({
// Converts a JS string to an integer base-10, with signaling error
// handling (throws a JS exception on error). E.g. jstoi_s("123abc")
// throws an exception.
$jstoi_s: (str) => Number(str),
$jstoi_s: 'Number',
#if LINK_AS_CXX
// libunwind
Expand Down
6 changes: 2 additions & 4 deletions src/library_async.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ addToLibrary({
_free(Asyncify.currData);
Asyncify.currData = null;
// Call all sleep callbacks now that the sleep-resume is all done.
Asyncify.sleepCallbacks.forEach((func) => callUserCallback(func));
Asyncify.sleepCallbacks.forEach(callUserCallback);
} else {
abort(`invalid state: ${Asyncify.state}`);
}
Expand Down Expand Up @@ -446,9 +446,7 @@ addToLibrary({
}
},
handleSleep(startAsync) {
return Asyncify.handleAsync(() => (
new Promise((wakeUp) => startAsync(wakeUp))
));
return Asyncify.handleAsync(() => new Promise(startAsync));
},
makeAsyncFunction(original) {
#if ASYNCIFY_DEBUG
Expand Down
2 changes: 1 addition & 1 deletion src/library_dylink.js
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ var LibraryDylink = {
var libFile = locateFile(libName);
if (flags.loadAsync) {
return new Promise(function(resolve, reject) {
asyncLoad(libFile, (data) => resolve(data), reject);
asyncLoad(libFile, resolve, reject);
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/library_eventloop.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ LibraryJSEventLoop = {
emscripten_set_timeout: (cb, msecs, userData) =>
safeSetTimeout(() => {{{ makeDynCall('vp', 'cb') }}}(userData), msecs),

emscripten_clear_timeout: (id) => clearTimeout(id),
emscripten_clear_timeout: 'clearTimeout',

emscripten_set_timeout_loop__deps: ['$callUserCallback', 'emscripten_get_now'],
emscripten_set_timeout_loop: (cb, msecs, userData) => {
Expand Down
2 changes: 1 addition & 1 deletion src/library_fs_shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ addToLibrary({
}
addRunDependency(dep);
if (typeof url == 'string') {
asyncLoad(url, (byteArray) => processData(byteArray), onerror);
asyncLoad(url, processData, onerror);
} else {
processData(url);
}
Expand Down
3 changes: 1 addition & 2 deletions src/library_html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,7 @@ var LibraryHTML5 = {
#endif
},
#else
$findCanvasEventTarget__deps: ['$findEventTarget'],
$findCanvasEventTarget: (target) => findEventTarget(target),
$findCanvasEventTarget: '$findEventTarget',
#endif

#else
Expand Down
2 changes: 1 addition & 1 deletion src/library_pthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ var LibraryPThread = {
_emscripten_notify_mailbox_postmessage__deps: ['$checkMailbox'],
_emscripten_notify_mailbox_postmessage: (targetThreadId, currThreadId, mainThreadId) => {
if (targetThreadId == currThreadId) {
setTimeout(() => checkMailbox());
setTimeout(checkMailbox);
} else if (ENVIRONMENT_IS_PTHREAD) {
postMessage({'targetThread' : targetThreadId, 'cmd' : 'checkMailbox'});
} else {
Expand Down
3 changes: 1 addition & 2 deletions src/library_sdl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1417,8 +1417,7 @@ var LibrarySDL = {
// bits-per-pixel of the closest available mode with the given width, height and requested surface flags
SDL_VideoModeOK: (width, height, depth, flags) => depth, // all modes are ok.

SDL_AudioDriverName__deps: ['SDL_VideoDriverName'],
SDL_AudioDriverName: (buf, max_size) => _SDL_VideoDriverName(buf, max_size),
SDL_AudioDriverName: 'SDL_VideoDriverName',

SDL_VideoDriverName__proxy: 'sync',
SDL_VideoDriverName: (buf, max_size) => {
Expand Down
2 changes: 1 addition & 1 deletion src/library_webgl2.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var LibraryWebGL2 = {
}
switch (name) {
case 0x1F03 /* GL_EXTENSIONS */:
var exts = GL.getExtensions().map((e) => stringToNewUTF8(e));
var exts = GL.getExtensions().map(stringToNewUTF8);
stringiCache = GL.stringiCache[name] = exts;
if (index < 0 || index >= stringiCache.length) {
GL.recordError(0x501/*GL_INVALID_VALUE*/);
Expand Down
2 changes: 1 addition & 1 deletion src/proxyWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ function messageResender() {
if (calledMain) {
assert(messageBuffer && messageBuffer.length > 0);
messageResenderTimeout = null;
messageBuffer.forEach((message) => onmessage(message));
messageBuffer.forEach(onmessage);
messageBuffer = null;
} else {
messageResenderTimeout = setTimeout(messageResender, 100);
Expand Down
2 changes: 1 addition & 1 deletion src/source_map_support.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function getSourceMapPromise() {
if ((ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) && typeof fetch == 'function') {
return fetch(wasmSourceMapFile, {{{ makeModuleReceiveExpr('fetchSettings', "{ credentials: 'same-origin' }") }}})
.then((response) => response['json']())
.catch(() => getSourceMap());
.catch(getSourceMap);
}
return new Promise(function(resolve, reject) {
resolve(getSourceMap());
Expand Down
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_ctors1.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10013
10012
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_ctors1.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24852
24846
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_ctors2.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24820
24814
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_except.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11121
11122
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_except.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
28982
28976
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_except_wasm.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24627
24621
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_mangle.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
28982
28976
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_noexcept.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10013
10012
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_noexcept.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24852
24846
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_wasmfs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5307
5308
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_wasmfs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12302
12296
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_dylink.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6533
6527
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_dylink.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14543
14537
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O0.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7295
7296
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_pthreads.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5034
5031
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_pthreads.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
13869
13863
2 changes: 1 addition & 1 deletion test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2558,7 +2558,7 @@ def test_runtime_misuse(self, mode):
''' % self.port

create_file('pre_runtime.js', r'''
Module.onRuntimeInitialized = () => myJSCallback();
Module.onRuntimeInitialized = myJSCallback;
''')

for filename, extra_args, second_code in [
Expand Down

0 comments on commit 546353b

Please sign in to comment.