Skip to content

Commit 467568d

Browse files
committed
use same hashCode in seqs and lists as in vectors
1 parent 2ea265f commit 467568d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/jvm/clojure/lang/ASeq.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,17 @@ public boolean equals(Object obj){
5252
public int hashCode(){
5353
if(_hash == -1)
5454
{
55-
int hash = 0;
55+
int hash = 1;
5656
for(ISeq s = seq(); s != null; s = s.rest())
5757
{
58-
hash = Util.hashCombine(hash, Util.hash(s.first()));
58+
hash = 31 * hash + (s.first() == null ? 0 : s.first().hashCode());
5959
}
6060
this._hash = hash;
6161
}
6262
return _hash;
6363
}
6464

65+
6566
//public Object reduce(IFn f) throws Exception{
6667
// Object ret = first();
6768
// for(ISeq s = rest(); s != null; s = s.rest())

src/jvm/clojure/lang/PersistentList.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ public Object reduce(IFn f, Object start) throws Exception{
114114

115115
static class EmptyList extends Obj implements IPersistentList, Collection{
116116

117+
@Override
118+
public int hashCode(){
119+
return 1;
120+
}
121+
117122
EmptyList(IPersistentMap meta){
118123
super(meta);
119124
}

0 commit comments

Comments
 (0)