perf(linter/plugins): faster conversion of span to Location#20507
Merged
graphite-app[bot] merged 1 commit intomainfrom Mar 21, 2026
Merged
Conversation
This was referenced Mar 18, 2026
This was referenced Mar 18, 2026
Member
Author
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes computeLoc in apps/oxlint/src-js/plugins/location.ts, which converts source spans (start/end offsets) into { start: { line, column }, end: { line, column } } locations used by nodes/tokens/comments during linting.
Changes:
- Adds a fast path in
computeLocfor the common case wherestartandendare on the same line. - Narrows the binary search range for locating
endto lines at/after the line containingstart. - Refactors
getLineColumnFromOffsetto return its{ line, column }result directly (removing the helper that populated an output object).
860d9dc to
a229810
Compare
This was referenced Mar 19, 2026
a229810 to
ee2f73e
Compare
f3c82c6 to
f5c738d
Compare
ee2f73e to
bf0cd7d
Compare
f5c738d to
897dc88
Compare
897dc88 to
bfa3661
Compare
bf0cd7d to
deb418b
Compare
Contributor
Merge activity
|
Speed up `computeLoc`, which converts a `start` + `end` offset pair to a `Location` of form `{ start: { line: ?, column: ? }, end: { line: ?, column: ? } }`.
`computeLoc` is only called with `start` and `end` pairs from AST nodes, tokens, and comments, which are all produced by Oxc's parser, so it's guaranteed that `start < end`.
Use this invariant for 2 optimizations:
1. Fast path for common case where `start` and `end` are on same line.
2. Reduce range of lines which are searched looking for end to only lines which are after the line `start` is on. `end` can't be on an earlier line, so there's not point search them.
bfa3661 to
f064f80
Compare
deb418b to
336f7f7
Compare
Base automatically changed from
om/03-18-docs_linter_plugins_correct_comment_about_offset_to_line-column_conversion
to
main
March 21, 2026 13:05
This was referenced Mar 23, 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.

Speed up
computeLoc, which converts astart+endoffset pair to aLocationof form{ start: { line: ?, column: ? }, end: { line: ?, column: ? } }.computeLocis only called withstartandendpairs from AST nodes, tokens, and comments, which are all produced by Oxc's parser, so it's guaranteed thatstart < end.Use this invariant for 2 optimizations:
startandendare on same line.startis on.endcan't be on an earlier line, so there's not point search them.