On Mon, 12 Apr 2021 09:32:27 GMT, Johan Vos <[email protected]> wrote:
>> modules/javafx.controls/src/main/java/javafx/scene/control/skin/VirtualFlow.java
>> line 2972:
>>
>>> 2970: // Make sure we have enough space in the cache to store this
>>> index
>>> 2971: while (idx >= itemSizeCache.size()) {
>>> 2972: itemSizeCache.add(itemSizeCache.size(), null);
>>
>> Can this be simplified to `itemSizeCache.add(null);`?
>
> That won't add enough elements. For example, in case idx = 10, and the
> itemSizeCache has 5 elements, we need to add 5 empty elements to the cache,
> as they might get queried/pushed, e.g. we might do
> `itemSizeCache.set(7, 123.45);`
Sure, that's why you need the `while` loop. What I meant is that the following
two calls are equivalent for any list:
list.add(list.size(), null);
and
list.add(null);
-------------
PR: https://git.openjdk.java.net/jfx/pull/398