Skip to content

Commit

Permalink
GH-3994 precompute hashCode for MemIRI
Browse files Browse the repository at this point in the history
  • Loading branch information
hmottestad committed Jun 19, 2022
1 parent ac63da0 commit 19d3f5e
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class MemIRI extends MemResource implements IRI {
/**
* The MemURI's hash code, 0 if not yet initialized.
*/
private volatile int hashCode = 0;
private final int hashCode;

/**
* The list of statements for which this MemURI is the predicate.
Expand All @@ -69,6 +69,7 @@ public MemIRI(Object creator, String namespace, String localName) {
this.creator = creator;
this.namespace = namespace;
this.localName = localName;
this.hashCode = (namespace + localName).hashCode();
}

/*---------*
Expand Down Expand Up @@ -147,10 +148,6 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
if (hashCode == 0) {
hashCode = stringValue().hashCode();
}

return hashCode;
}

Expand Down

0 comments on commit 19d3f5e

Please sign in to comment.