Patch: New hash function

Tom Tromey tromey@cygnus.com
Wed Aug 16 08:29:00 GMT 2000


I'm checking this in.  This should give us a better hash function both
on 32- and 64-bit machines.

2000-08-15  Andrew Haley  <aph@cygnus.com>

	* include/jvm.h (_Jv_HashCode): New hash code.

Tom

Index: include/jvm.h
===================================================================
RCS file: /cvs/java/libgcj/libjava/include/jvm.h,v
retrieving revision 1.25
diff -u -r1.25 jvm.h
--- jvm.h	2000/05/31 23:50:37	1.25
+++ jvm.h	2000/08/16 15:28:25
@@ -163,7 +163,9 @@
 inline jint
 _Jv_HashCode (jobject obj)
 {
-  return (jint) obj;
+  // This was chosen to yield relatively well distributed results on
+  // both 32- and 64-bit architectures.
+  return (jint) ((unsigned long long) obj % 0x7fffffff);
 }
 
 // Return a raw pointer to the elements of an array given the array


More information about the Java-patches mailing list