On Tue, 21 Dec 2021 15:35:32 GMT, Kevin Rushforth <k...@openjdk.org> wrote:

>> Good point. All the test cases that I could think of were already present in 
>> `MultipleSelectionModelImplTest`. Nevertheless, test cases for different 
>> `set()` methods can definitely be added. I will work on it.
>
> What about the first part of my question? Have you looked at the set logic to 
> ensure that `size` is being invalidated in all places it should be. The 
> `set(int index, int... indices)` method does not directly invalidate `size`. 
> If that method unconditionally set `size = -1`, it would be easier to prove 
> that there are no missed cases.

This is a cache of the cardinality method of BitSet, not Lazy evaluation. It 
sets invalidity (-1) in the method call that changes the bit. This could be a 
subclass of BitSet to make the code more readable. This patch does not subclass 
BitSet because there is no case where it is used in the same way.
If it were to be subclassed, it would be possible to reduce the number of 
cardinality calls if it were calculated wisely instead of simply being disabled.

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

PR: https://git.openjdk.java.net/jfx/pull/673

Reply via email to