Skip to content

perf: avoid split() when locating lines - #338

Open
Nic-Polumeyv wants to merge 1 commit into
Rich-Harris:masterfrom
Nic-Polumeyv:perf/avoid-split
Open

perf: avoid split() when locating lines#338
Nic-Polumeyv wants to merge 1 commit into
Rich-Harris:masterfrom
Nic-Polumeyv:perf/avoid-split

Conversation

@Nic-Polumeyv

Copy link
Copy Markdown

getLocator split the whole source into an array of lines just to compute line offsets, and Mappings.advance split every intro, outro and edit to count newlines. Both now use indexOf and keep only the offsets and counts. Output is unchanged; pnpm bench on this machine moves generateDecodedMap (no edit) from 2,269 to 2,426 hz, the rest is within noise.

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