This is the mail archive of the
java-patches@sources.redhat.com
mailing list for the Java project.
Patch: New hash function
- To: Java Patch List <java-patches at sourceware dot cygnus dot com>
- Subject: Patch: New hash function
- From: Tom Tromey <tromey at cygnus dot com>
- Date: 16 Aug 2000 09:34:59 -0600
- Reply-To: tromey at cygnus dot com
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