Skip to content

Commit 713c2f4

Browse files
authored
Micro-optimize zeroMemory / mmapAlloc. NFC (#22713)
We can skip the return statement from zeroMemory and reduce the number of return statements in mmapAlloc to just one.
1 parent 9e37a10 commit 713c2f4

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/library.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ addToLibrary({
6262
}
6363
#endif
6464
HEAPU8.fill(0, address, address + size);
65-
return address;
6665
},
6766

6867
#if SAFE_HEAP
@@ -2278,8 +2277,8 @@ addToLibrary({
22782277
#if hasExportedSymbol('emscripten_builtin_memalign')
22792278
size = alignMemory(size, {{{ WASM_PAGE_SIZE }}});
22802279
var ptr = _emscripten_builtin_memalign({{{ WASM_PAGE_SIZE }}}, size);
2281-
if (!ptr) return 0;
2282-
return zeroMemory(ptr, size);
2280+
if (ptr) zeroMemory(ptr, size);
2281+
return ptr;
22832282
#elif ASSERTIONS
22842283
abort('internal error: mmapAlloc called but `emscripten_builtin_memalign` native symbol not exported');
22852284
#else

0 commit comments

Comments
 (0)