Skip to content

perf: walk unedited chunks line by line when generating mappings - #339

Merged
antfu merged 2 commits into
Rich-Harris:masterfrom
Nic-Polumeyv:perf/unedited-chunk-lines
Sep 10, 2026
Merged

perf: walk unedited chunks line by line when generating mappings#339
antfu merged 2 commits into
Rich-Harris:masterfrom
Nic-Polumeyv:perf/unedited-chunk-lines

Conversation

@Nic-Polumeyv

@Nic-Polumeyv Nic-Polumeyv commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Generating mappings for unedited chunks no longer visits every character, which makes generateMap about 3x faster on the benchmark (generateMap (no edit) 1,912 -> 5,617 hz, generateDecodedMap (edit) 2,197 -> 7,354 hz; hires: true unchanged, it is bound by segment allocation).

Without hires only line starts and explicit addSourcemapLocation positions produce segments, so addUneditedChunk jumps between newlines and reads those positions from the BitSet words. The hires modes keep the per-character loop but test word characters by char code instead of a regex. Mappings are byte-identical across the test suite and a comparison harness (CRLF, unicode, empty inputs, every edit method).

@antfu
antfu merged commit 910a39c into Rich-Harris:master Sep 10, 2026
3 checks passed
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.

2 participants