#102
Table-free SWAR integer formatting (~1.8x hex / ~1.6x dec)
Replaces the lookup-table number formatting in Format.c with branchless
SWAR cores that convert multiple digits at once inside one 32/64-bit word.
Removes the 200-byte DECIMAL_LOOKUP table and the hex digit-char literals.
Benchmarks
Microbenchmark over the public ZyanStringAppend{Hex,Dec}U API, clang -O2 -march=native, x86-64. Indicative, not guaranteed.
| workload | this PR | baseline | speedup |
|---|---|---|---|
AppendHexU, realistic operand mix | ~3.7 ns/op | ~6.7 ns/op | ~1.8× |
AppendDecU, mixed 1–20 digit | ~9.0 ns/op | ~14.1 ns/op | ~1.6× |
Notes
- One code path for both endians; only the final store is endian-sensitive
(
ZyanStoreLE32/ZyanStoreLE64). - Adds
tests/Format.cpp(differential vssnprintf; the module had none), registered in CMake and Meson. - Verified clean: clang
-Wall -Wextra -pedantic -Werror, MSVC x64/x86/W4 /WX. - Not run here (would appreciate CI): big-endian, GCC, ASan/UBSan, 32-bit runtime.