RFR: 8306447: Adding an element to a long existing list may cause the first visible element to jump

Marius Hanl mhanl at openjdk.org
Thu Apr 20 08:07:56 UTC 2023


On Thu, 20 Apr 2023 07:17:39 GMT, Johan Vos <jvos at openjdk.org> wrote:

>> modules/javafx.controls/src/main/java/javafx/scene/control/skin/VirtualFlow.java line 858:
>> 
>>> 856: 
>>> 857:         @Override protected void invalidated() {
>>> 858:             int oldIndex = computeCurrentIndex();
>> 
>> I wonder if we can cache the old index somewhere since the _compute..._ methods can take some time on big tables.
>
> I think an instance variable makes sense, as the current index is a property of a specific VirtualFlow instance.
> That won't help with performance though, as we still need to compute the current index in a number of cases. Instead of calling the `computeCurrentIndex()` we would then just update the instance variable. 
> To fix the issue, we need to reduce the cases where the current index is recomputed (or bring it to zero in case the current index can't theoretically change) , and this is what #1098 is about -- so your comment probably belongs to #1098?
> I'll experiment with instance fields, and try to reduce the computations even more.

Agreed. And good idea! I will also do a bunch of tests when I have time. :)

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1099#discussion_r1172228207


More information about the openjfx-dev mailing list