Skip to content

Scan whitespace, line breaks and keywords without building strings - #151

Open
Gal Be (g4lb) wants to merge 1 commit into
microsoft:mainfrom
g4lb:perf-scanner-trivia
Open

Gal Be (g4lb) wants to merge 1 commit into
microsoft:mainfrom
g4lb:perf-scanner-trivia

Conversation

@g4lb

Copy link
Copy Markdown

The scanner now reads whitespace values only when getTokenValue() asks for them, and it matches true, false and null without a substring. The tokens do not change.

Built lib/esm, µs per call, 20 rounds, Mann-Whitney test (Node 24, Apple M2 Max):

Benchmark Before After Change
createScanner(), indented JSON 505 334 −33.9%
parse(), indented JSON 935 751 −19.7%
parse(), package-lock.json 590 506 −14.3%

Other inputs show no slowdown. Tests pass. Outputs matched on 1M random inputs.

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