RFR: 8357687: Remove unnecessary Map.containsKey from GraphicsEnvironment implementations

Damon Nguyen dnguyen at openjdk.org
Thu Jul 31 20:08:57 UTC 2025


On Sun, 27 Apr 2025 21:04:34 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:

> `devices` contains only non-null values. It means instead of separate `containsKey` call we can just call `HashMap.get` and then compare result with `null`.

I do agree that this is probably a subjective change. I think both are fairly clear and there's basically no impact to code performance I'd imagine. In my opinion, the old code's `containsKey` is slightly easier to follow than `d != null` but there's barely any difference.

Since I just reviewed https://github.com/openjdk/jdk/pull/24852 which is similar, I'll follow the same logic and agree with the change here too.

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

Marked as reviewed by dnguyen (Committer).

PR Review: https://git.openjdk.org/jdk/pull/24907#pullrequestreview-3076745122


More information about the client-libs-dev mailing list