changeset 30760:c5077abd4ef2

(hashfn_eq, hashfn_eql): Don't handle strings specially since they aren't relocated anymore. (sxhash_string): Make sure returned hash code fits in a Lisp integer.
author Gerd Moellmann <gerd@gnu.org>
date Fri, 11 Aug 2000 12:59:31 +0000
parents 408aec5f514c
children 8218291cc912
files src/fns.c
diffstat 1 files changed, 15 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/fns.c	Fri Aug 11 08:38:51 2000 +0000
+++ b/src/fns.c	Fri Aug 11 12:59:31 2000 +0000
@@ -3852,12 +3852,9 @@
      struct Lisp_Hash_Table *h;
      Lisp_Object key;
 {
-  /* Lisp strings can change their address.  Don't try to compute a
-     hash code for a string from its address.  */
-  if (STRINGP (key))
-    return sxhash_string (XSTRING (key)->data, XSTRING (key)->size);
-  else
-    return XUINT (key) ^ XGCTYPE (key);
+  unsigned hash = XUINT (key) ^ XGCTYPE (key);
+  xassert ((hash & ~VALMASK) == 0);
+  return hash;
 }
 
 
@@ -3870,14 +3867,13 @@
      struct Lisp_Hash_Table *h;
      Lisp_Object key;
 {
-  /* Lisp strings can change their address.  Don't try to compute a
-     hash code for a string from its address.  */
-  if (STRINGP (key))
-    return sxhash_string (XSTRING (key)->data, XSTRING (key)->size);
-  else if (FLOATP (key))
-    return sxhash (key, 0);
+  unsigned hash;
+  if (FLOATP (key))
+    hash = sxhash (key, 0);
   else
-    return XUINT (key) ^ XGCTYPE (key);
+    hash = XUINT (key) ^ XGCTYPE (key);
+  xassert ((hash & ~VALMASK) == 0);
+  return hash;
 }
 
 
@@ -3890,7 +3886,9 @@
      struct Lisp_Hash_Table *h;
      Lisp_Object key;
 {
-  return sxhash (key, 0);
+  unsigned hash = sxhash (key, 0);
+  xassert ((hash & ~VALMASK) == 0);
+  return hash;
 }
 
 
@@ -4445,7 +4443,8 @@
       + (unsigned)(Y))
 
 
-/* Return a hash for string PTR which has length LEN.  */
+/* Return a hash for string PTR which has length LEN.  The hash
+   code returned is guaranteed to fit in a Lisp integer.  */
 
 static unsigned
 sxhash_string (ptr, len)
@@ -4465,7 +4464,7 @@
       hash = ((hash << 3) + (hash >> 28) + c);
     }
 
-  return hash & 07777777777;
+  return hash & VALMASK;
 }