RFR: 8287285: Avoid redundant HashMap.containsKey call in java.util.zip.ZipFile.Source.get

Alan Bateman alanb at openjdk.java.net
Thu May 26 08:31:24 UTC 2022


On Sat, 30 Apr 2022 08:56:23 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:

> The method `java.util.zip.ZipFile.Source#get` could be improved by usage of `Map.putIfAbsent` instead of separate `containsKey`/`get`/`put` calls. We known that HashMap `java.util.zip.ZipFile.Source#files` can contain only non-null values. And to check if putIfAbsent was successful or not we can just compare result with `null`.
> It makes code a bit cleaner and faster.

Marked as reviewed by alanb (Reviewer).

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

PR: https://git.openjdk.java.net/jdk/pull/8481


More information about the core-libs-dev mailing list