There is overload method HashMap.remove(key,value) which also checks value equality. It's shorter and faster than pair get+remove.
------------- Commit messages: - [PATCH] Remove redundant HashMap.get call before HashMap.remove Changes: https://git.openjdk.org/jdk/pull/9314/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=9314&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8289431 Stats: 2 lines in 1 file changed: 0 ins; 1 del; 1 mod Patch: https://git.openjdk.org/jdk/pull/9314.diff Fetch: git fetch https://git.openjdk.org/jdk pull/9314/head:pull/9314 PR: https://git.openjdk.org/jdk/pull/9314