Skip to content

fix(editor): avoid quadratic input slot filtering - #3415

Open
aofei wants to merge 1 commit into
goplus:devfrom
aofei:perf-large-input-slots
Open

fix(editor): avoid quadratic input slot filtering#3415
aofei wants to merge 1 commit into
goplus:devfrom
aofei:perf-large-input-slots

Conversation

@aofei

@aofei aofei commented Aug 13, 2026

Copy link
Copy Markdown
Member

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.

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread spx-gui/src/components/xgo-code-editor/input-helper.ts Outdated
Comment thread spx-gui/src/components/xgo-code-editor/input-helper.ts
Comment thread spx-gui/src/components/xgo-code-editor/input-helper.ts
Comment thread spx-gui/src/components/xgo-code-editor/input-helper.test.ts
Comment thread tools/spxls/go.mod
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]>
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