jfx icon indicating copy to clipboard operation
jfx copied to clipboard

8283063: Optimize Observable{List/Set/Map}Wrapper.retainAll/removeAll

Open mstr2 opened this issue 3 years ago • 5 comments

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.


Progress

  • [x] Change must not contain extraneous whitespace
  • [x] Commit message must refer to an issue
  • [ ] Change must be properly reviewed

Issue

  • JDK-8283063: Optimize Observable{List/Set/Map}Wrapper.retainAll/removeAll

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jfx pull/751/head:pull/751
$ git checkout pull/751

Update a local copy of the PR:
$ git checkout pull/751
$ git pull https://git.openjdk.java.net/jfx pull/751/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 751

View PR using the GUI difftool:
$ git pr show -t 751

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jfx/pull/751.diff

mstr2 avatar Mar 12 '22 04:03 mstr2

:wave: Welcome back mstrauss! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

bridgekeeper[bot] avatar Mar 12 '22 04:03 bridgekeeper[bot]

Webrevs

mlbridge[bot] avatar Mar 12 '22 05:03 mlbridge[bot]

/reviewers 2

kevinrushforth avatar Mar 12 '22 14:03 kevinrushforth

@kevinrushforth The number of required reviews for this PR is now set to 2 (with at least 1 of role reviewers).

openjdk[bot] avatar Mar 12 '22 14:03 openjdk[bot]

This is an equivalent change that partially includes the fix I proposed in #305. It is good to apply it to Map / Set.

yososs avatar Mar 19 '22 00:03 yososs

@mstr2 this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout fixes/JDK-8283063
git fetch https://git.openjdk.org/jfx.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

openjdk[bot] avatar Apr 01 '23 03:04 openjdk[bot]

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).

mstr2 avatar Apr 01 '23 03:04 mstr2

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.

mstr2 avatar Apr 01 '23 18:04 mstr2

@hjohn Can you re-approve?

mstr2 avatar Apr 05 '23 05:04 mstr2

@mstr2 This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8283063: Optimize Observable{List/Set/Map}Wrapper.retainAll/removeAll

Reviewed-by: nlisker, jhendrikx

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 5 new commits pushed to the master branch:

  • 810bd90d5089364067549b8ba299300bfd208357: 8286089: Intermittent WebKit build failure on macOS in JavaScriptCore
  • a264435dccba6ec386548f76f1ace095d943f4ca: 8282359: Intermittent WebKit build failure on Windows: C1090: PDB API call failed, error code 23
  • 4c0e0bd96adc02be721203193aed1d8676db9ebb: 8305248: TableView not rendered correctly after column is made visible if fixed cell size is set
  • c23d067db92789daadc28025fab31f394ce022f9: 8304960: ObservableListBase should defer constructing ListChangeBuilder
  • 2a5bf4647ca19f67eb56f2459f0a5acee6c05146: 8304924: [testbug] Skip failing tests on Linux

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch. As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

openjdk[bot] avatar Apr 05 '23 10:04 openjdk[bot]

/integrate

mstr2 avatar Apr 05 '23 12:04 mstr2

Going to push as commit b6e5737c7a25544f61778254613a4dd42ca2b96c. Since your change was applied there have been 5 commits pushed to the master branch:

  • 810bd90d5089364067549b8ba299300bfd208357: 8286089: Intermittent WebKit build failure on macOS in JavaScriptCore
  • a264435dccba6ec386548f76f1ace095d943f4ca: 8282359: Intermittent WebKit build failure on Windows: C1090: PDB API call failed, error code 23
  • 4c0e0bd96adc02be721203193aed1d8676db9ebb: 8305248: TableView not rendered correctly after column is made visible if fixed cell size is set
  • c23d067db92789daadc28025fab31f394ce022f9: 8304960: ObservableListBase should defer constructing ListChangeBuilder
  • 2a5bf4647ca19f67eb56f2459f0a5acee6c05146: 8304924: [testbug] Skip failing tests on Linux

Your commit was automatically rebased without conflicts.

openjdk[bot] avatar Apr 05 '23 12:04 openjdk[bot]

@mstr2 Pushed as commit b6e5737c7a25544f61778254613a4dd42ca2b96c.

:bulb: You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

openjdk[bot] avatar Apr 05 '23 12:04 openjdk[bot]