RFR: 8197991: Selecting many items in a TableView is very slow
Abhinay Agarwal
duke at openjdk.java.net
Mon Nov 22 15:58:20 UTC 2021
On Thu, 18 Nov 2021 09:06:08 GMT, Tom Schindl <tschindl at openjdk.org> wrote:
>> 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
I could move `int max = size();` outside the loop
-------------
PR: https://git.openjdk.java.net/jfx/pull/673
More information about the openjfx-dev
mailing list