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 and cstamas committed Aug 2, 2024
1 parent 02e1d87 commit a84011c
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,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 @@ -295,6 +297,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 a84011c

Please sign in to comment.