RFR: 8283063: Optimize Observable{List/Set/Map}Wrapper.retainAll/removeAll [v2]
Michael Strauß
mstrauss at openjdk.org
Sat Apr 1 03:25:28 UTC 2023
> `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
-------------
Changes:
- all: https://git.openjdk.org/jfx/pull/751/files
- new: https://git.openjdk.org/jfx/pull/751/files/af84b648..9a0e29a4
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jfx&pr=751&range=01
- incr: https://webrevs.openjdk.org/?repo=jfx&pr=751&range=00-01
Stats: 679 lines in 11 files changed: 573 ins; 72 del; 34 mod
Patch: https://git.openjdk.org/jfx/pull/751.diff
Fetch: git fetch https://git.openjdk.org/jfx.git pull/751/head:pull/751
PR: https://git.openjdk.org/jfx/pull/751
More information about the openjfx-dev
mailing list