Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/lib/libbase64.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ addToLibrary({
// Decodes a _known valid_ base64 string (without validation) and returns it as a new Uint8Array.
// Benchmarked to be around 5x faster compared to a simple
// "Uint8Array.from(atob(b64), c => c.charCodeAt(0))" (TODO: perhaps use this form in -Oz builds?)
#if !JS_BASE64_API
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does does JS_BASE64_API relate to SINGLE_FILE_BINARY_ENCODE? The PR description only talks about that later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry, that was not so clear with GitHub diff.

By static reading the base64Decode() function starts

  $base64Decode: (b64) => {
#if JS_BASE64_API
    return Uint8Array.fromBase64(b64);
#else

i.e. the base64ReverseLookup object is never accessed if JS_BASE64_API is defined. So I updated the ifdef here to be consistent with that scenario as well.

$base64Decode__postset: `
// Precreate a reverse lookup table from chars
// "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" back to
Expand All @@ -20,6 +21,7 @@ addToLibrary({
base64ReverseLookup[43] = 62; // '+'
base64ReverseLookup[47] = 63; // '/'
`,
#endif
$base64Decode__docs: '/** @noinline */',
$base64Decode: (b64) => {
#if JS_BASE64_API
Expand Down
2 changes: 1 addition & 1 deletion tools/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -1969,7 +1969,7 @@ def phase_emscript(in_wasm, wasm_target, js_syms, base_metadata):

# No need to support base64 embedding in wasm2js mode since
# the module is already in JS format.
if settings.SINGLE_FILE and not settings.WASM2JS:
if settings.SINGLE_FILE and not settings.SINGLE_FILE_BINARY_ENCODE and not settings.WASM2JS:
settings.SUPPORT_BASE64_EMBEDDING = 1
settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE.append('$base64Decode')

Expand Down
Loading