Skip to content

Commit c9ca59a

Browse files
committed
Few more manual replacements
1 parent 07a0a8f commit c9ca59a

File tree

8 files changed

+20
-20
lines changed

8 files changed

+20
-20
lines changed

src/library.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3115,7 +3115,7 @@ addToLibrary({
31153115
#else
31163116
assert(('dynCall_' + sig) in Module, `bad function pointer type - dynCall function not found for sig '${sig}'`);
31173117
#endif
3118-
if (args && args.length) {
3118+
if (args?.length) {
31193119
#if WASM_BIGINT
31203120
// j (64-bit integer) is fine, and is implemented as a BigInt. Without
31213121
// legalization, the number of parameters should match (j is not expanded

src/library_async.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ addToLibrary({
439439
// WebAssembly.Functions.
440440
asyncExports: null,
441441
isAsyncExport(func) {
442-
return Asyncify.asyncExports && Asyncify.asyncExports.has(func);
442+
return Asyncify.asyncExports?.has(func);
443443
},
444444
handleAsync: async (startAsync) => {
445445
{{{ runtimeKeepalivePush(); }}}

src/library_browser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ var LibraryBrowser = {
10221022
// to queue the newest produced audio samples.
10231023
// TODO: Consider adding pre- and post- rAF callbacks so that GL.newRenderingFrameStarted() and SDL.audio.queueNewAudioData()
10241024
// do not need to be hardcoded into this function, but can be more generic.
1025-
if (typeof SDL == 'object' && SDL.audio && SDL.audio.queueNewAudioData) SDL.audio.queueNewAudioData();
1025+
if (typeof SDL == 'object') SDL.audio?.queueNewAudioData?.();
10261026

10271027
Browser.mainLoop.scheduler();
10281028
}

src/library_fs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1606,7 +1606,7 @@ FS.staticInit();` +
16061606
},
16071607
close(stream) {
16081608
// flush any pending line data
1609-
if (output && output.buffer && output.buffer.length) {
1609+
if (output?.buffer?.length) {
16101610
output({{{ charCode('\n') }}});
16111611
}
16121612
},

src/library_html5_webgl.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ var LibraryHtml5WebGL = {
3131
}
3232

3333
HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.alpha }}}>>2)] =
34-
HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.depth }}}>>2)] =
35-
HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.antialias }}}>>2)] =
36-
HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.premultipliedAlpha }}}>>2)] =
37-
HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.majorVersion }}}>>2)] =
34+
HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.depth }}}>>2)] =
35+
HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.antialias }}}>>2)] =
36+
HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.premultipliedAlpha }}}>>2)] =
37+
HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.majorVersion }}}>>2)] =
3838
HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.enableExtensionsByDefault }}}>>2)] = 1;
3939

4040
#if PTHREADS
@@ -473,7 +473,7 @@ var LibraryHtml5WebGL = {
473473
emscripten_webgl_get_vertex_attrib_o__proxy: 'sync_on_current_webgl_context_thread',
474474
emscripten_webgl_get_vertex_attrib_o: (index, param) => {
475475
var obj = GLctx.getVertexAttrib(index, param);
476-
return obj && obj.name;
476+
return obj?.name;
477477
},
478478

479479
emscripten_webgl_get_vertex_attrib_v__proxy: 'sync_on_current_webgl_context_thread',
@@ -502,7 +502,7 @@ var LibraryHtml5WebGL = {
502502
emscripten_webgl_get_parameter_o__proxy: 'sync_on_current_webgl_context_thread',
503503
emscripten_webgl_get_parameter_o: (param) => {
504504
var obj = GLctx.getParameter(param);
505-
return obj && obj.name;
505+
return obj?.name;
506506
},
507507

508508
emscripten_webgl_get_parameter_utf8__deps: ['$stringToNewUTF8'],

src/library_openal.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,7 +1886,7 @@ var LibraryOpenAL = {
18861886
};
18871887
18881888
// The latest way to call getUserMedia()
1889-
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
1889+
if (navigator.mediaDevices?.getUserMedia) {
18901890
navigator.mediaDevices
18911891
.getUserMedia({audio: true})
18921892
.then(onSuccess)
@@ -1911,11 +1911,11 @@ var LibraryOpenAL = {
19111911
// This clean-up might be unnecessary (paranoid) ?
19121912
19131913
// May happen if user hasn't decided to grant or deny input
1914-
if (c.mediaStreamSourceNode) c.mediaStreamSourceNode.disconnect();
1915-
if (c.mergerNode) c.mergerNode.disconnect();
1916-
if (c.splitterNode) c.splitterNode.disconnect();
1914+
c.mediaStreamSourceNode?.disconnect();
1915+
c.mergerNode?.disconnect();
1916+
c.splitterNode?.disconnect();
19171917
// May happen if user hasn't decided to grant or deny input
1918-
if (c.scriptProcessorNode) c.scriptProcessorNode.disconnect();
1918+
c.scriptProcessorNode?.disconnect();
19191919
if (c.mediaStream) {
19201920
// Disabling the microphone of the browser.
19211921
// Without this operation, the red dot on the browser tab page will remain.

src/library_sdl.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,7 @@ var LibrarySDL = {
15041504
}
15051505
}
15061506
var audio = /** @type {HTMLMediaElement} */ (SDL.music.audio);
1507-
if (audio) audio.pause();
1507+
audio?.pause();
15081508
SDL.music.audio = undefined;
15091509
},
15101510

@@ -2394,7 +2394,7 @@ var LibrarySDL = {
23942394

23952395
#if ASYNCIFY
23962396
var sleepCallback = () => {
2397-
if (SDL.audio && SDL.audio.queueNewAudioData) SDL.audio.queueNewAudioData();
2397+
SDL.audio?.queueNewAudioData?.();
23982398
};
23992399
Asyncify.sleepCallbacks.push(sleepCallback);
24002400
SDL.audio.callbackRemover = () => {
@@ -2933,13 +2933,13 @@ var LibrarySDL = {
29332933
Mix_PauseMusic__proxy: 'sync',
29342934
Mix_PauseMusic: () => {
29352935
var audio = /** @type {HTMLMediaElement} */ (SDL.music.audio);
2936-
if (audio) audio.pause();
2936+
audio?.pause();
29372937
},
29382938

29392939
Mix_ResumeMusic__proxy: 'sync',
29402940
Mix_ResumeMusic: () => {
29412941
var audio = SDL.music.audio;
2942-
if (audio) audio.play();
2942+
audio?.play();
29432943
},
29442944

29452945
Mix_HaltMusic__proxy: 'sync',

src/postamble.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ function checkUnflushedContent() {
307307
var stream = info.object;
308308
var rdev = stream.rdev;
309309
var tty = TTY.ttys[rdev];
310-
if (tty && tty.output && tty.output.length) {
310+
if (tty?.output?.length) {
311311
has = true;
312312
}
313313
});

0 commit comments

Comments
 (0)