Skip to content

v5: split into PbfReader and PbfWriter#143

Open
mourner wants to merge 5 commits into
mainfrom
v5
Open

v5: split into PbfReader and PbfWriter#143
mourner wants to merge 5 commits into
mainfrom
v5

Conversation

@mourner
Copy link
Copy Markdown
Member

@mourner mourner commented May 22, 2026

Breaking change: the single Pbf class is split into PbfReader and PbfWriter, allowing readers and writers to be tree-shaken independently in bundled apps.

Removed: the legacy readVarint64 method (replaced by readVarint(true) for signed 64-bit reads).

Performance: several targeted optimizations to both read and write hot paths, validated against bench/bench-tiles.js:

  • makeRoomForExtraLength uses Uint8Array.copyWithin instead of a manual byte-shift loop (biggest write win).
  • writeVarint gets a single-byte fast path, skipping the multi-byte branches and full realloc(4) for the common case (tags, small ints).
  • readVarint gets a matching single-byte fast path.
  • writeBytes uses typedArray.set instead of a manual loop.

End-to-end on the tile benchmark: write throughput improved from ~169 MB/s to ~215 MB/s (~27% faster), and read throughput from ~150 MB/s to ~157 MB/s (~5% faster).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant