changeset 46:4022c34a4804

Better hashCode impl
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 14 Jan 2011 04:56:53 +0100
parents 70dafe20931d
children b01500fe2604
files src/com/tmate/hgkit/ll/Nodeid.java
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
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