perf: replace base64.h with simdutf SIMD-accelerated codec#50
Closed
GrzywN wants to merge 1 commit into
Closed
Conversation
Closes craftzdog#42 Replace the René Nyffenegger base64.h codec with simdutf v8.2.0 (used by Node.js, Bun, Deno). Encode uses binary_to_base64 directly; decode mirrors V8's Uint8Array.fromBase64 via base64_to_binary_safe (loose, decode_up_to_bad_char=true). Behaviour changes (now TC39-compliant): - mid-string padding (e.g. SQ==QU0=) is rejected instead of silently decoded - \n in input without removeLinebreaks=true throws instead of being ignored
Contributor
Author
|
The
|
Owner
|
Amazing. Thanks! |
Closed
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #42
Replaces the René Nyffenegger
base64.hcodec with simdutf v8.2.0 — the same SIMD-accelerated base64 library used internally by Node.js, Bun, and Deno. The library is vendored as an amalgamated single-file (simdutf.h+simdutf.cpp), keeping the same zero-external-dependency setup as before.Encode (
base64FromArrayBuffer) callssimdutf::binary_to_base64directly.Decode (
base64ToArrayBuffer) mirrors V8'sUint8Array.fromBase64implementation viasimdutf::base64_to_binary_safewithlooselast-chunk handling anddecode_up_to_bad_char=true.Behaviour changes (TC39-compliant)
SQ==QU0=)[73, 65, 77]Invalid base64\nwithoutremoveLinebreaksInvalid base64\nwithremoveLinebreaks=true-_)=paddingFiles changed
cpp/simdutf.hcpp/simdutf.cppcpp/base64.hcpp/react-native-quick-base64.cppandroid/CMakeLists.txtbase64.h→simdutf.cppin sourcesexample/src/tests/corrupt.tsexample/src/tests/linebreaks.tsiOS podspec (
cpp/**/*.{h,cpp}) picks upsimdutf.h/.cppautomatically — no podspec changes needed.Screenshots