perf: inline getArg(line/column) in originalPositionFor and generatedPositionFor#72
Merged
Merged
Conversation
This was referenced May 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
originalPositionForandgeneratedPositionForstill went throughutil.getArgfor the requiredline/columnargs (PR #63 only inlined the constructor's optional reads). The profile showedgetArgself-time at 2.4% of opf and 2.3% of gpf — but the actual cost was much larger than that: thegetArgcall site was megamorphic across many call paths in the codebase, blocking V8 from specializing the per-call shape.This PR inlines the two required reads to direct property accesses. To preserve the documented "is a required argument" error (which getArg threw via its missing-key branch), an explicit
typeof !== 'number'guard runs before the existing range check.Results (bench-diff vs main, SOLO)
babel.min.js.map
Full-phase run also clean: Init / eachMapping all within ±3% noise.
vscode.map
API note
The required-argument error type changes from
Error(thrown byutil.getArg) → stillError, message format identical. Same throw semantics for missing key andundefinedvalue (slightly tighter than before — previouslyundefinedvalue silently produced wrong results).Test plan
yarn test— 205/205 non-TODO tests pass