Expand description
Base64 (RFC 4648) encode and decode: NEON on ARM64, AVX2/SSSE3 on x86_64, scalar elsewhere.
Decoding is strict: no whitespace, padding exactly as the engine says, and the unused bits of the last group must be zero, so every byte string has one accepted encoding.
§Performance (x86_64 AVX2, encode_to_string / decode_to_vec, allocation included)
| bytes | encode | decode | decode, base64-simd 0.8 |
|---|---|---|---|
| 48 | 20 ns | 17 ns | 25 ns |
| 600 | 71 ns | 55 ns | 93 ns |
| 64 K | 6.2 µs | 4.9 µs | 8.5 µs |
Encoding is level with base64-simd from 32 bytes up.
§Algorithm
NEON: vld3/vst4 de-interleave 48 bytes into 64 indices, and a 64-entry tbl4 maps
them to the alphabet. Decoding runs the same in reverse over a 128-entry tbl4/tbx4 table.
SSSE3/AVX2: Muła and Lemire’s multiply-shift split and pshufb offset lookup. Decode
validation classifies each byte by nibble pair (lut_lo[lo] & lut_hi[hi]), with tables built
at compile time from the alphabet, so the URL-safe engine uses the same code.
Structs§
Constants§
- STANDARD
- The standard alphabet, padded.
- URL_
SAFE_ NO_ PAD - The URL-safe alphabet, unpadded.