On Thu, 18 Nov 2021 09:06:08 GMT, Tom Schindl <tschi...@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