这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@leewyatt
Copy link
Collaborator

Summary

This PR improves the robustness and efficiency of the selectIndices(int, int...) method in CustomMultipleSelectionModel. It addresses both functional correctness and performance optimization:

Key Improvements

  • Avoids repeated listener notifications
    Previously, selecting indices one-by-one triggered multiple selection events and list mutations. This version performs batch updates to minimize unnecessary UI refreshes and observable change events.

  • Null-safe handling for int... indices
    Prevents NullPointerException if null is passed.

  • Single-pass filtering
    Combines validation, deduplication, and unselected checks in a single stream.

  • No-op guard
    Efficiently skips updates if all indices are already selected.

  • Predictive memory allocation
    Uses new ArrayList<>(1 + indices.length) to avoid internal array resizing.

  • Consistent final selection state
    Aligns with JavaFX: in both SINGLE and MULTIPLE selection modes, the last valid index is treated as the active one (selectedIndex, selectedItem).

…e and correctness

- Avoids repeated listener triggers by batch-processing selection updates
- Handles null input for varargs indices to prevent NullPointerException
- Filters and deduplicates valid indices in a single pass
- Skips redundant updates if all requested indices are already selected
- Preallocates internal list with expected size to reduce GC pressure
- Ensures consistent final selection state in both SINGLE and MULTIPLE modes
@leewyatt leewyatt requested a review from dlemmermann April 21, 2025 12:11
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@dlemmermann dlemmermann merged commit eecfd4d into master Apr 28, 2025
3 of 4 checks passed
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.

3 participants