Skip to content

Commit 7ac1a3d

Browse files
committed
Remove redundant assertion from emscripten_console_* functions. NFC
The UTF8ToString functions that these all call has this assertion already and with a useful message.
1 parent 4faa282 commit 7ac1a3d

1 file changed

Lines changed: 10 additions & 37 deletions

File tree

src/lib/libcore.js

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,44 +1967,17 @@ addToLibrary({
19671967
_emscripten_get_progname__deps: ['$getExecutableName', '$stringToUTF8'],
19681968
_emscripten_get_progname: (str, len) => stringToUTF8(getExecutableName(), str, len),
19691969

1970-
emscripten_console_log: (str) => {
1971-
#if ASSERTIONS
1972-
assert(typeof str == 'number');
1973-
#endif
1974-
console.log(UTF8ToString(str));
1975-
},
1976-
1977-
emscripten_console_warn: (str) => {
1978-
#if ASSERTIONS
1979-
assert(typeof str == 'number');
1980-
#endif
1981-
console.warn(UTF8ToString(str));
1982-
},
1970+
// These single-line arrow functions use curly braces since otherwise closure
1971+
// compiler will inject a extra `return` keyword when inlining.
1972+
// https://github.com/emscripten-core/emscripten/issues/26922
1973+
emscripten_console_log: (str) => { console.log(UTF8ToString(str)) },
1974+
emscripten_console_warn: (str) => { console.warn(UTF8ToString(str)) },
1975+
emscripten_console_error: (str) => { console.error(UTF8ToString(str)) },
1976+
emscripten_console_trace: (str) => { console.trace(UTF8ToString(str)) },
19831977

1984-
emscripten_console_error: (str) => {
1985-
#if ASSERTIONS
1986-
assert(typeof str == 'number');
1987-
#endif
1988-
console.error(UTF8ToString(str));
1989-
},
1978+
emscripten_throw_number: (number) => { throw number; },
19901979

1991-
emscripten_console_trace: (str) => {
1992-
#if ASSERTIONS
1993-
assert(typeof str == 'number');
1994-
#endif
1995-
console.trace(UTF8ToString(str));
1996-
},
1997-
1998-
emscripten_throw_number: (number) => {
1999-
throw number;
2000-
},
2001-
2002-
emscripten_throw_string: (str) => {
2003-
#if ASSERTIONS
2004-
assert(typeof str == 'number');
2005-
#endif
2006-
throw UTF8ToString(str);
2007-
},
1980+
emscripten_throw_string: (str) => { throw UTF8ToString(str); },
20081981

20091982
#if !MINIMAL_RUNTIME
20101983
#if STACK_OVERFLOW_CHECK
@@ -2185,7 +2158,7 @@ addToLibrary({
21852158

21862159
$alignMemory: (size, alignment) => {
21872160
#if ASSERTIONS
2188-
assert(alignment, "alignment argument is required");
2161+
assert(alignment, 'alignment argument is required');
21892162
#endif
21902163
return Math.ceil(size / alignment) * alignment;
21912164
},

0 commit comments

Comments
 (0)