comparison src/com/tmate/hgkit/ll/Nodeid.java @ 46:4022c34a4804

Better hashCode impl
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 14 Jan 2011 04:56:53 +0100
parents 858d1b2458cb
children
comparison
equal deleted inserted replaced
45:70dafe20931d 46:4022c34a4804
35 this.binaryData = shallClone ? binaryRepresentation.clone() : binaryRepresentation; 35 this.binaryData = shallClone ? binaryRepresentation.clone() : binaryRepresentation;
36 } 36 }
37 37
38 @Override 38 @Override
39 public int hashCode() { 39 public int hashCode() {
40 // TODO consider own impl, especially if byte[] get replaced with 5 ints 40 // digest (part thereof) seems to be nice candidate for the hashCode
41 return Arrays.hashCode(binaryData); 41 byte[] b = binaryData;
42 return b[0] << 24 | (b[1] & 0xFF) << 16 | (b[2] & 0xFF) << 8 | (b[3] & 0xFF);
42 } 43 }
43 44
44 @Override 45 @Override
45 public boolean equals(Object o) { 46 public boolean equals(Object o) {
46 if (o instanceof Nodeid) { 47 if (o instanceof Nodeid) {