From 434a5f0f046d3ae9325949bd12c4054d18df6c9d 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 80ab3c154..87194b6fa 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 @@ -234,9 +234,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 @@ -253,6 +255,10 @@ public boolean equals(Object o) { @Override public int hashCode() { + return hashCode; + } + + private int buildHashCode() { return Objects.hashCode(artifact); }