Skip to content

Commit 33b7810

Browse files
committed
symbol hash tweaks
1 parent be77d0a commit 33b7810

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/jvm/clojure/lang/Symbol.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ public class Symbol extends AFn implements IObj, Comparable, Named, Serializable
2020
//these must be interned strings!
2121
final String ns;
2222
final String name;
23-
final int hash;
24-
final int hasheq;
23+
private int _hasheq = -1;
2524
final IPersistentMap _meta;
2625
String _str;
2726

@@ -68,8 +67,6 @@ static public Symbol intern(String nsname){
6867
private Symbol(String ns_interned, String name_interned){
6968
this.name = name_interned;
7069
this.ns = ns_interned;
71-
this.hash = Util.hashCombine(name.hashCode(), Util.hash(ns));
72-
this.hasheq = Util.hashCombine(Murmur3.hashUnencodedChars(name), ns==null?0:Murmur3.hashUnencodedChars(ns));
7370
this._meta = null;
7471
}
7572

@@ -86,11 +83,14 @@ public boolean equals(Object o){
8683
}
8784

8885
public int hashCode(){
89-
return hash;
86+
return Util.hashCombine(name.hashCode(), Util.hash(ns));
9087
}
9188

9289
public int hasheq() {
93-
return hasheq;
90+
if(_hasheq == -1){
91+
_hasheq = Util.hashCombine(Murmur3.hashUnencodedChars(name), Util.hash(ns));
92+
}
93+
return _hasheq;
9494
}
9595

9696
public IObj withMeta(IPersistentMap meta){
@@ -101,8 +101,6 @@ private Symbol(IPersistentMap meta, String ns, String name){
101101
this.name = name;
102102
this.ns = ns;
103103
this._meta = meta;
104-
this.hash = Util.hashCombine(name.hashCode(), Util.hash(ns));
105-
this.hasheq = Util.hashCombine(Murmur3.hashUnencodedChars(name), ns==null?0:Murmur3.hashUnencodedChars(ns));
106104
}
107105

108106
public int compareTo(Object o){

0 commit comments

Comments
 (0)