fix(editor): avoid quadratic input slot filtering - #3415
Open
aofei wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Review: perf — filter large input slots
The rewrite of the nested-slot filter from an O(n²) rangeContains scan to an O(n log n) sort-and-sweep is correct and semantically equivalent to the previous behavior — including the subtle "two slots with identical ranges are both dropped" case, the crossing/partial-overlap case (both kept), and the preservation of original input order. Complexity is genuinely linearithmic with no accidental quadratic paths, and the LSP-sourced input is handled safely (no injection/DoS concern).
Findings are all non-blocking maintainability/coverage items, plus one dependency note. See inline comments. No approval or change-request is implied — this is an informational review.
Sort input slots by source range and remove nested or duplicate ranges with a single scan. This keeps input helper initialization responsive for projects that contain tens of thousands of editable literals. Add coverage for nested, crossing, duplicate, and large flat slot sets. Signed-off-by: Aofei Sheng <[email protected]>
aofei
force-pushed
the
perf-large-input-slots
branch
from
August 13, 2026 08:36
ddb52f0 to
74e482b
Compare
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.
Sort input slots by source range and remove nested or duplicate ranges with a single scan. This keeps input helper initialization responsive for projects that contain tens of thousands of editable literals.
Add coverage for nested, crossing, duplicate, and large flat slot sets.