From 19d3f5e29371f9709b76e7455a1f8ce10ce314bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ha=CC=8Avard=20Ottestad?= Date: Sat, 18 Jun 2022 13:32:13 +0200 Subject: [PATCH] GH-3994 precompute hashCode for MemIRI --- .../java/org/eclipse/rdf4j/sail/memory/model/MemIRI.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/core/sail/memory/src/main/java/org/eclipse/rdf4j/sail/memory/model/MemIRI.java b/core/sail/memory/src/main/java/org/eclipse/rdf4j/sail/memory/model/MemIRI.java index 4757ee86c91..79e009ddc0b 100644 --- a/core/sail/memory/src/main/java/org/eclipse/rdf4j/sail/memory/model/MemIRI.java +++ b/core/sail/memory/src/main/java/org/eclipse/rdf4j/sail/memory/model/MemIRI.java @@ -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. @@ -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(); } /*---------* @@ -147,10 +148,6 @@ public boolean equals(Object o) { @Override public int hashCode() { - if (hashCode == 0) { - hashCode = stringValue().hashCode(); - } - return hashCode; }