Mercurial > hg4j
diff 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 |
line wrap: on
line diff
--- a/src/com/tmate/hgkit/ll/Nodeid.java Fri Jan 14 04:52:33 2011 +0100 +++ b/src/com/tmate/hgkit/ll/Nodeid.java Fri Jan 14 04:56:53 2011 +0100 @@ -37,8 +37,9 @@ @Override public int hashCode() { - // TODO consider own impl, especially if byte[] get replaced with 5 ints - return Arrays.hashCode(binaryData); + // digest (part thereof) seems to be nice candidate for the hashCode + byte[] b = binaryData; + return b[0] << 24 | (b[1] & 0xFF) << 16 | (b[2] & 0xFF) << 8 | (b[3] & 0xFF); } @Override