jfx
jfx copied to clipboard
8283063: Optimize Observable{List/Set/Map}Wrapper.retainAll/removeAll
Observable{List/Set/Map}Wrapper.retainAll/removeAll can be optimized for some edge cases.
-
removeAll(c): This is a no-op if 'c' is empty. ForObservableListWrapper, returning early skips an object allocation. ForObservableSetWrapperandObservableMapWrapper, returning early prevents an enumeration of the entire collection. -
retainAll(c): This is a no-op if the backing collection is empty, or equivalent toclear()ifcis 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
: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.
Webrevs
- 04: Full - Incremental (91260638)
- 03: Full - Incremental (6ea639b6)
- 02: Full (682bdf80)
- 01: Full - Incremental (9a0e29a4)
- 00: Full (af84b648)
/reviewers 2
@kevinrushforth The number of required reviews for this PR is now set to 2 (with at least 1 of role reviewers).
This is an equivalent change that partially includes the fix I proposed in #305. It is good to apply it to Map / Set.
@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
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).
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.
@hjohn Can you re-approve?
@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.
/integrate
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.
@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.