RFR: 8283063: Optimize Observable{List/Set/Map}Wrapper.retainAll/removeAll [v4]

Michael Strauß mstrauss at openjdk.org
Sat Apr 1 18:14:11 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 one additional commit since the last revision:

  addressed review comments, added tests

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

Changes:
  - all: https://git.openjdk.org/jfx/pull/751/files
  - new: https://git.openjdk.org/jfx/pull/751/files/682bdf80..6ea639b6

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jfx&pr=751&range=03
 - incr: https://webrevs.openjdk.org/?repo=jfx&pr=751&range=02-03

  Stats: 464 lines in 10 files changed: 207 ins; 34 del; 223 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