RFR: 8197991: Selecting many items in a TableView is very slow
Tom Schindl
tschindl at openjdk.java.net
Thu Nov 18 09:08:44 UTC 2021
On Thu, 18 Nov 2021 00:55:18 GMT, Nir Lisker <nlisker at openjdk.org> wrote:
>> This work improves the performance of `MultipleSelectionModel` over large data sets by caching some values and avoiding unnecessary calls to `SelectedIndicesList#size`. It further improves the performance by reducing the number of iterations required to find the index of an element in the BitSet.
>>
>> The work is based on [an abandoned patch](https://github.com/openjdk/jfx/pull/127) submitted by @yososs
>>
>> There are currently 2 manual tests for this fix.
>
> modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/ReadOnlyUnbackedObservableList.java line 119:
>
>> 117: Object obj = get(i);
>> 118: if (o.equals(obj)) return i;
>> 119: }
>
> An alternative is
>
> return IntStream.range(0, size())
> .filter(i -> o.equals(get(i)))
> .findFirst()
> .orElse(-1);
>
> I don't know if it helps.
the for-loop is certainly faster and would allocate less memory - i find the `for(int i = 0, max = size())`-style a bit odd
-------------
PR: https://git.openjdk.java.net/jfx/pull/673
More information about the openjfx-dev
mailing list