RFR: 8357686: Remove unnecessary Map.get from AWTAutoShutdown.unregisterPeer

Alexey Ivanov aivanov at openjdk.org
Mon Jun 16 15:01:56 UTC 2025


On Thu, 24 Apr 2025 20:18:01 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:

> Instead of separate `.get(Key)`+`.remove(Key)` calls we can call `.remove(Key, Value)`.
> `peerMap` is an `IdentityHashMap`. IdentityHashMap.remove compares values with == since Java 20 ([JDK-8178355](https://bugs.openjdk.org/browse/JDK-8178355))

Looks fine.

The code now depends on the fact that `peerMap` is an `IdentityHashMap` which may be not such a good thing.

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

Marked as reviewed by aivanov (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/24858#pullrequestreview-2932501820


More information about the client-libs-dev mailing list