Integrated: 8287603: Avoid redundant HashMap.containsKey calls in NimbusDefaults.getDerivedColor
Andrey Turbanov
aturbanov at openjdk.org
Tue Jul 5 07:41:44 UTC 2022
On Sat, 30 Apr 2022 09:33:38 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:
> 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`.
> https://github.com/openjdk/jdk/blob/97bd4c255a319ce626a316ed211ef1fd7d0f1e14/src/java.desktop/share/classes/javax/swing/plaf/nimbus/Defaults.template#L713-L720
> It makes code a bit cleaner and faster.
This pull request has now been integrated.
Changeset: fd1bb078
Author: Andrey Turbanov <aturbanov at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/fd1bb078ea3c8d3a10be696384ecf04d16573baa
Stats: 5 lines in 1 file changed: 1 ins; 1 del; 3 mod
8287603: Avoid redundant HashMap.containsKey calls in NimbusDefaults.getDerivedColor
Reviewed-by: attila, aivanov
-------------
PR: https://git.openjdk.org/jdk/pull/8482
More information about the client-libs-dev
mailing list