Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8287603: Avoid redundant HashMap.containsKey calls in NimbusDefaults.getDerivedColor #8482

Conversation

turbanoff
Copy link
Member

@turbanoff turbanoff commented Apr 30, 2022

The method javax.swing.plaf.nimbus.NimbusDefaults#getDerivedColor(String,String,float,float,float,int,boolean) could be improved by usage of Map.putIfAbsent instead of separate containsKey/get/put calls. We known that HashMap javax.swing.plaf.nimbus.NimbusDefaults#derivedColors can contain only non-null values. And to check if putIfAbsent was successful or not, we can just compare result with null.

if (derivedColors.containsKey(color)) {
return derivedColors.get(color);
} else {
derivedColors.put(color, color);
color.rederiveColor(); /// move to ARP.decodeColor() ?
colorTree.addColor(uin, color);
return color;
}

It makes code a bit cleaner and faster.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8287603: Avoid redundant HashMap.containsKey calls in NimbusDefaults.getDerivedColor

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/8482/head:pull/8482
$ git checkout pull/8482

Update a local copy of the PR:
$ git checkout pull/8482
$ git pull https://git.openjdk.org/jdk pull/8482/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 8482

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/8482.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 30, 2022

👋 Welcome back aturbanov! 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.

@openjdk
Copy link

openjdk bot commented Apr 30, 2022

@turbanoff The following label will be automatically applied to this pull request:

  • client

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the client client-libs-dev@openjdk.org label Apr 30, 2022
@bridgekeeper
Copy link

bridgekeeper bot commented May 28, 2022

@turbanoff This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@turbanoff turbanoff changed the title [PATCH] Avoid redundant HashMap.containsKey calls in NimbusDefaults 8287603: Avoid redundant HashMap.containsKey calls in NimbusDefaults.getDerivedColor May 31, 2022
@openjdk openjdk bot added the rfr Pull request is ready for review label May 31, 2022
@mlbridge
Copy link

mlbridge bot commented May 31, 2022

Webrevs

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 29, 2022

@turbanoff This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@openjdk
Copy link

openjdk bot commented Jul 3, 2022

@turbanoff 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:

8287603: Avoid redundant HashMap.containsKey calls in NimbusDefaults.getDerivedColor

Reviewed-by: attila, aivanov

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 906 new commits pushed to the master branch:

  • a8edd7a: 8289569: [test] java/lang/ProcessBuilder/Basic.java fails on Alpine/musl
  • e31003a: 8289575: G1: Remove unnecessary is-marking-active check in G1BarrierSetRuntime::write_ref_field_pre_entry
  • 8e7a3cb: 8289431: (zipfs) Avoid redundant HashMap.get in ZipFileSystemProvider.removeFileSystem
  • 649f2d8: 8065097: [macosx] javax/swing/Popup/TaskbarPositionTest.java fails because Popup is one pixel off
  • d8444aa: 8286610: Add additional diagnostic output to java/net/DatagramSocket/InterruptibleDatagramSocket.java
  • 70f5693: Merge
  • f5cdaba: 8245268: -Xcomp is missing from java launcher documentation
  • 9515560: 8288703: GetThreadState returns 0 for virtual thread that has terminated
  • cfc9a88: 8288854: getLocalGraphicsEnvironment() on for multi-screen setups throws exception NPE
  • 9925014: 8280320: C2: Loop opts are missing during OSR compilation
  • ... and 896 more: https://git.openjdk.org/jdk/compare/d9541c5e9f68f2b76e6e1d09bc24750b7c9a5b5b...master

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 openjdk bot added the ready Pull request is ready to be integrated label Jul 3, 2022
@turbanoff
Copy link
Member Author

Thank you for review!

/integrate

@openjdk
Copy link

openjdk bot commented Jul 5, 2022

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

  • 4c997ba: 8289520: G1: Remove duplicate checks in G1BarrierSetC1::post_barrier
  • 1b997db: 8289427: compiler/compilercontrol/jcmd/ClearDirectivesFileStackTest.java failed with null setting
  • 688712f: 8289633: Forbid raw C-heap allocation functions in hotspot and fix findings
  • df063f7: 8289484: Cleanup unnecessary null comparison before instanceof check in java.rmi
  • 9ccae70: 8287593: ShortResponseBody could be made more resilient to rogue connections
  • bad9ffe: 8288947: G1: Consolidate per-region is-humongous query in G1CollectedHeap
  • b5d9656: 8288971: AArch64: Clean up stack and register handling in interpreter
  • d53b02e: 8287312: G1: Early return on first failure in VerifyRegionClosure
  • a8edd7a: 8289569: [test] java/lang/ProcessBuilder/Basic.java fails on Alpine/musl
  • e31003a: 8289575: G1: Remove unnecessary is-marking-active check in G1BarrierSetRuntime::write_ref_field_pre_entry
  • ... and 904 more: https://git.openjdk.org/jdk/compare/d9541c5e9f68f2b76e6e1d09bc24750b7c9a5b5b...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 5, 2022
@openjdk openjdk bot closed this Jul 5, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jul 5, 2022
@openjdk
Copy link

openjdk bot commented Jul 5, 2022

@turbanoff Pushed as commit fd1bb07.

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

@turbanoff turbanoff deleted the redundant_Map.containsKey_in_NimbusDefaults branch October 27, 2022 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client client-libs-dev@openjdk.org integrated Pull request has been integrated
3 participants