RFR: 8283063: Optimize Observable{List/Set/Map}Wrapper.retainAll/removeAll [v4]
Michael Strauß
mstrauss at openjdk.org
Sat Apr 1 18:34:25 UTC 2023
On Sat, 1 Apr 2023 18:14:11 GMT, Michael Strauß <mstrauss at openjdk.org> 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 one additional commit since the last revision:
>
> addressed review comments, added tests
I've added comments in all places where implicit null checks are important to satisfy the collection contract.
In addition to that, I've also re-organized the tests using nested test classes, and added explicit null tests for all relevant code paths.
-------------
PR Comment: https://git.openjdk.org/jfx/pull/751#issuecomment-1493068555
More information about the openjfx-dev
mailing list