On Sun, 15 Mar 2026 11:38:42 GMT, chuckyschluz <[email protected]> wrote:

>> Fixes [JDK-8311505](https://bugs.openjdk.org/browse/JDK-8311505)
>> 
>> This PR uses `set(int index, int end, boolean isSet)` in 
>> `javafx.scene.control.MultipleSelectionModelBase` to avoid excessive calls 
>> to `indexOf` when deselecting continuous ranges of rows. 
>> 
>> Benchmarks produced with the test application provided here: 
>> https://bugs.openjdk.org/browse/JDK-8311505
>> 
>> Before (mainline):
>> 
>> 
>> Select item count 500000 took 724
>> Deselect item count 500000 took 73103
>> 
>> 
>> After (this PR):
>> 
>> 
>> Select item count 500000 took 249
>> Deselect item count 500000 took 88
>> 
>> 
>> Passes all unit tests:
>> 
>> `.\gradlew.bat :controls:test`
>> `.\gradlew.bat :systemTests:test`
>> 
>> Thank you!
>
> chuckyschluz has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   minor cleanup

> It is related to calling `clearSelection(int)` in a loop in 
> `CellBehaviorBase.java`, but these changes alone don't fix it. The solution 
> is pretty simple and passes all tests. Should I add that to this PR?
> 
> ```diff
> -        // To prevent JDK-8123898, we make a copy of the selected indices
> -        // list first, so that we are not iterating and modifying it
> -        // concurrently.
> -        List<Integer> selectedIndices = new 
> ArrayList<>(getSelectionModel().getSelectedIndices());
> -        for (int i = 0, max = selectedIndices.size(); i < max; i++) {
> -            int selectedIndex = selectedIndices.get(i);
> -            if (selectedIndex < minRow || selectedIndex > maxRow) {
> -                getSelectionModel().clearSelection(selectedIndex);
> -            }
> -        }
> +        getSelectionModel().clearSelection();
> ```

No, I would address this separately and not expand this PR to include it.

The above class is otherwise not touched by this PR, and this change has a high 
risk of introducing a regression. We don't have sufficient tests in this area 
to conclude that passing all of them means that the fix is OK.

-------------

PR Comment: https://git.openjdk.org/jfx/pull/2100#issuecomment-4067180745

Reply via email to