Skip to content

Commit

Permalink
Make sure we cache the hashCode as it will be called a lot (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet authored Aug 2, 2024
1 parent d4e6f65 commit 434a5f0
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,11 @@ public void putChildren(Object key, List<DependencyNode> 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
Expand All @@ -253,6 +255,10 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return hashCode;
}

private int buildHashCode() {
return Objects.hashCode(artifact);
}

Expand Down

0 comments on commit 434a5f0

Please sign in to comment.