Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes spelling-suggestion generation across the compiler by switching candidate enumeration to iter.Seq-based iteration, avoiding large slice materializations and (in some cases) expensive full sorts while preserving deterministic results via explicit tie-breaking.
Changes:
- Refactors
core.GetSpellingSuggestionto acceptiter.Seqcandidates and a comparison function for deterministic tie-breaking. - Adds
core.FilterSeqand updates multiple call sites to use iterator-based candidate production (maps.Keys,slices.Values,core.ConcatenateSeq). - Removes symbol-slice construction/sorting in several checker paths by iterating symbol tables directly and tie-breaking with
c.compareSymbols.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/core/core.go | Introduces FilterSeq; refactors spelling-suggestion API to use iter.Seq and explicit tie-breaking. |
| internal/checker/checker.go | Updates symbol/type suggestion paths to use iterator-based candidates, avoiding full symbol-slice sorts. |
| internal/checker/jsx.go | Switches JSX attribute suggestion to pass property candidates via slices.Values. |
| internal/parser/parser.go | Uses iterator-based keyword candidates for missing-semicolon diagnostics. |
| internal/compiler/processingDiagnostic.go | Uses iterator-based lib-name candidates for “cannot find lib” diagnostics. |
| internal/scanner/regexp.go | Uses maps.Keys/ConcatenateSeq iterators for Unicode property name/value spelling suggestions. |
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.
Follow-up to #1640 and #3100 / #3100 (comment)
In bad code, the spelling checks can be very expensive. We can avoid sorting large symbol tables by instead just using iterators, keeping track of the best candidate. Only on tie breaks do we call a comparison function, which for symbols will be
c.compareSymbols, the thing we would have sorted all symbols with anyway.Also improves a few other cases where we can now use iterators instead of constructing big slices just to toss them away.
I'll note that in Strada, this was way less of a problem because we put a hard limit on how many spelling checks we would do. We got rid of that limit because it causes nondeterminism. So this becomes a bit more perf critical.