Skip to content

Commit dd0c250

Browse files
authored
Use JS optional chaining in more places. NFC (emscripten-core#22087)
1 parent 8a79a40 commit dd0c250

File tree

64 files changed

+67
-67
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+67
-67
lines changed

src/library.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3357,7 +3357,7 @@ function wrapSyscallFunction(x, library, isWasi) {
33573357
var canThrow = library[x + '__nothrow'] !== true;
33583358
#endif
33593359

3360-
if (!library[x + '__deps']) library[x + '__deps'] = [];
3360+
library[x + '__deps'] ??= [];
33613361

33623362
#if PURE_WASI
33633363
// In PURE_WASI mode we can't assume the wasm binary was built by emscripten

src/library_browser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ var LibraryBrowser = {
869869
Browser.setImmediate = /** @type{function(function(): ?, ...?): number} */(function Browser_emulated_setImmediate(func) {
870870
setImmediates.push(func);
871871
if (ENVIRONMENT_IS_WORKER) {
872-
if (Module['setImmediates'] === undefined) Module['setImmediates'] = [];
872+
Module['setImmediates'] ??= [];
873873
Module['setImmediates'].push(func);
874874
postMessage({target: emscriptenMainLoopMessageId}); // In --proxy-to-worker, route the message via proxyClient.js
875875
} else postMessage(emscriptenMainLoopMessageId, "*"); // On the main thread, can just send the message to itself.

src/library_glfw.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,8 +1184,8 @@ var LibraryGLFW = {
11841184
Browser.updateResizeListeners();
11851185
}
11861186
}
1187-
if (Module['onFullScreen']) Module['onFullScreen'](Browser.isFullscreen);
1188-
if (Module['onFullscreen']) Module['onFullscreen'](Browser.isFullscreen);
1187+
Module['onFullScreen']?.(Browser.isFullscreen);
1188+
Module['onFullscreen']?.(Browser.isFullscreen);
11891189
}
11901190

11911191
if (!Browser.fullscreenHandlersInstalled) {

src/library_html5_webgl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ function handleWebGLProxying(funcs) {
541541
funcs[i + '_main_thread'] = i + '_calling_thread';
542542
funcs[i + '_main_thread__proxy'] = 'sync';
543543
funcs[i + '_main_thread__sig'] = sig;
544-
if (!funcs[i + '__deps']) funcs[i + '__deps'] = [];
544+
funcs[i + '__deps'] ??= [];
545545
funcs[i + '__deps'].push(i + '_calling_thread');
546546
funcs[i + '__deps'].push(i + '_main_thread');
547547
delete funcs[i + '__proxy'];

src/postamble.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ function run() {
220220
readyPromiseResolve(Module);
221221
#endif
222222
#if expectToReceiveOnModule('onRuntimeInitialized')
223-
if (Module['onRuntimeInitialized']) Module['onRuntimeInitialized']();
223+
Module['onRuntimeInitialized']?.();
224224
#endif
225225

226226
#if HAS_MAIN

src/proxyWorker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ function onMessageFromMainEmscriptenThread(message) {
475475
break;
476476
}
477477
case 'setimmediate': {
478-
if (Module['setImmediates']) Module['setImmediates'].shift()();
478+
Module['setImmediates']?.shift()();
479479
break;
480480
}
481481
default: throw 'wha? ' + message.data.target;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9756
1+
9761
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
23909
1+
23884
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9740
1+
9744
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
23877
1+
23852

0 commit comments

Comments
 (0)