Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-3994 precompute hashCode for MemIRI #3995

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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