From a84011ca1fb70169e0d8a917db6801621f92bc15 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Fri, 2 Aug 2024 11:19:27 +0200 Subject: [PATCH] Make sure we cache the hashCode as it will be called a lot (#6) --- .../org/eclipse/aether/internal/impl/collect/DataPool.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/DataPool.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/DataPool.java index d5ac4162f..9e9849e03 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/DataPool.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/DataPool.java @@ -276,9 +276,11 @@ public void putChildren(Object key, List children) { public static final class DescriptorKey { private final Artifact artifact; + private final int hashCode; private DescriptorKey(Artifact artifact) { this.artifact = artifact; + this.hashCode = buildHashCode(); } @Override @@ -295,6 +297,10 @@ public boolean equals(Object o) { @Override public int hashCode() { + return hashCode; + } + + private int buildHashCode() { return Objects.hashCode(artifact); }