On Sat, 1 Apr 2023 03:25:28 GMT, Michael Strauß <[email protected]> wrote:
>> `Observable{List/Set/Map}Wrapper.retainAll/removeAll` can be optimized for
>> some edge cases.
>>
>> 1. `removeAll(c)`:
>> This is a no-op if 'c' is empty.
>> For `ObservableListWrapper`, returning early skips an object allocation. For
>> `ObservableSetWrapper` and `ObservableMapWrapper`, returning early prevents
>> an enumeration of the entire collection.
>>
>> 2. `retainAll(c)`:
>> This is a no-op if the backing collection is empty, or equivalent to
>> `clear()` if `c` is empty.
>>
>> I've added some tests to verify the optimized behavior for each of the three
>> classes.
>
> Michael Strauß has updated the pull request incrementally with two additional
> commits since the last revision:
>
> - address review comments
> - refactored removeAll/retainAll optimizations
I've added the suggested optimization for
`ModifiableObservableListBase.addAll`, as well as
`ObservableSequentialListWrapper.addAll`.
Additionally, there are more tests to ensure adherence of the optimized methods
to the collection contracts (NPE and IOOBE should be thrown for invalid
arguments).
-------------
PR Comment: https://git.openjdk.org/jfx/pull/751#issuecomment-1492816029