Skip to content

Commit 96258ad

Browse files
Merge pull request #10 from valaphee/array-hashcode-fix
Make hashing order independent again
2 parents 67a66a5 + 3845685 commit 96258ad

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/main/java/org/cloudburstmc/nbt/NbtMap.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,9 @@ public boolean equals(Object o) {
386386
public int hashCode() {
387387
if (this.hashCodeGenerated)
388388
return this.hashCode;
389-
int result = 1;
390-
for (Entry<String, Object> stringObjectEntry : this.map.entrySet()) {
391-
result = 31 * result + (stringObjectEntry.getKey().hashCode()
392-
^ NbtUtils.hashCode(stringObjectEntry.getValue()));
393-
}
389+
int result = 0;
390+
for (Entry<String, Object> stringObjectEntry : this.map.entrySet())
391+
result += stringObjectEntry.getKey().hashCode() ^ NbtUtils.hashCode(stringObjectEntry.getValue());
394392
this.hashCode = result;
395393
this.hashCodeGenerated = true;
396394
return result;

0 commit comments

Comments
 (0)