mirror of
https://github.com/hanzoai/zap.git
synced 2026-10-30 18:17:49 +00:00
Before: Writer::to_bytes allocated two Vecs (slot region + tail) and copied the tail into the slot Vec at the end. Two allocations per encode + a copy. The bench numbers were: encode/keys_subscribe 436 ns (slower than format!() at 134 ns) encode/keys_snapshot_2k 736 ns (~1 GiB/s) Now: pre-compute total size from declared slot + each Text/Data field's length, allocate one Vec, append var-length payloads in-place at a running tail offset. Result: encode/keys_subscribe 86 ns (5× faster, beats JSON's 114 ns) encode/keys_snapshot_2k 268 ns (~7.5 GiB/s, 2.7× faster) decode/keys_subscribe 18 ns (unchanged — was already alloc-free) Six runtime tests still pass; the change is codegen-only.
Symbolic link
6 B
Symbolic link
6 B
LLM.md