RFR: 8287285: Avoid redundant HashMap.containsKey call in java.util.zip.ZipFile.Source.get
Jaikiran Pai
jpai at openjdk.java.net
Thu May 26 07:31:46 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.
The change looks fine to me. Please wait for at least one more review from someone having more knowledge of this area, before merging.
-------------
Marked as reviewed by jpai (Committer).
PR: https://git.openjdk.java.net/jdk/pull/8481
More information about the core-libs-dev
mailing list