On Mon, 18 May 2026 21:32:56 GMT, Andy Goryachev <[email protected]> wrote:

>> `update()` and `permutate()` do not call it anymore. I relocated them into 
>> one single location: Here.
>> So functionality wise, it did not change.
>> 
>> We could probably remove it, as we will catch any grow on size in 
>> `addRemove()`. But it might hurt performance.
>> If we have a `FilteredList` with a size 1 and add 10_000 elements, we will 
>> call `ensureSize` a lot of times, which will lead to a degraded performance. 
>> 
>> But since we call it once here, we will immediately grow to the worst case 
>> size - if nothing need to be filtered and MAY only grow it in `addRemove()` 
>> when we temporarily have more elements due to processing the changes one by 
>> one.
>
> I might be misunderstanding something.  
> 
> 1. Is `ensureSize()` L138 needed for `permutate()` ?
> 2. `addRemove()` calls `ensureSize()` twice (L138 and L237).  can it call it 
> only once?
> 3. `update()` does not change the filtered size, right?  why is it calling 
> `ensureSize()` in L138?

1. No - but when we are only sorting (permutation) the list, the `ensureSize` 
should be a noop, since the size had to be increased at some point in the past 
to what we currently have and ensured the size
2. No - because a sub change temporarily adds an element which is later removed 
on another sub change. We unfortunately can not predict that/count that in 
beforehand in this `ensureSize` call. With that said, the second call in 
`addRemove` should happen very rarely - probably only with small sizes
3. It can. When we change an item, lets say A -> B and A is filtered out but B 
is not, we grow in size by 1 (or the other way around). But same as in the 
`permutation`,- the `ensureSize` should be a noop, since the size had to be 
increased at some point in the past to what we currently have and ensured the 
size

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

PR Review Comment: https://git.openjdk.org/jfx/pull/2163#discussion_r3262462905

Reply via email to