Skip to content

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

Open
Nic-Polumeyv wants to merge 1 commit into
Rich-Harris:masterfrom
Nic-Polumeyv:perf/unedited-chunk-lines
Open

perf: walk unedited chunks line by line when generating mappings#339
Nic-Polumeyv wants to merge 1 commit 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

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).

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