aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann2000-08-11 12:59:31 +0000
committerGerd Moellmann2000-08-11 12:59:31 +0000
commitcf6818892f2e3dabcd649a326b88428440f1b03d (patch)
tree26c379974575395123361b8d710c287249ecf207 /src
parent8c1bec7c1d9029dfc4774a808cd09991f725a75a (diff)
downloademacs-cf6818892f2e3dabcd649a326b88428440f1b03d.tar.gz
emacs-cf6818892f2e3dabcd649a326b88428440f1b03d.zip
(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.
Diffstat (limited to 'src')
-rw-r--r--src/fns.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/fns.c b/src/fns.c
index 69b9427998f..1f53ecb4a04 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -3852,12 +3852,9 @@ hashfn_eq (h, key)
3852 struct Lisp_Hash_Table *h; 3852 struct Lisp_Hash_Table *h;
3853 Lisp_Object key; 3853 Lisp_Object key;
3854{ 3854{
3855 /* Lisp strings can change their address. Don't try to compute a 3855 unsigned hash = XUINT (key) ^ XGCTYPE (key);
3856 hash code for a string from its address. */ 3856 xassert ((hash & ~VALMASK) == 0);
3857 if (STRINGP (key)) 3857 return hash;
3858 return sxhash_string (XSTRING (key)->data, XSTRING (key)->size);
3859 else
3860 return XUINT (key) ^ XGCTYPE (key);
3861} 3858}
3862 3859
3863 3860
@@ -3870,14 +3867,13 @@ hashfn_eql (h, key)
3870 struct Lisp_Hash_Table *h; 3867 struct Lisp_Hash_Table *h;
3871 Lisp_Object key; 3868 Lisp_Object key;
3872{ 3869{
3873 /* Lisp strings can change their address. Don't try to compute a 3870 unsigned hash;
3874 hash code for a string from its address. */ 3871 if (FLOATP (key))
3875 if (STRINGP (key)) 3872 hash = sxhash (key, 0);
3876 return sxhash_string (XSTRING (key)->data, XSTRING (key)->size);
3877 else if (FLOATP (key))
3878 return sxhash (key, 0);
3879 else 3873 else
3880 return XUINT (key) ^ XGCTYPE (key); 3874 hash = XUINT (key) ^ XGCTYPE (key);
3875 xassert ((hash & ~VALMASK) == 0);
3876 return hash;
3881} 3877}
3882 3878
3883 3879
@@ -3890,7 +3886,9 @@ hashfn_equal (h, key)
3890 struct Lisp_Hash_Table *h; 3886 struct Lisp_Hash_Table *h;
3891 Lisp_Object key; 3887 Lisp_Object key;
3892{ 3888{
3893 return sxhash (key, 0); 3889 unsigned hash = sxhash (key, 0);
3890 xassert ((hash & ~VALMASK) == 0);
3891 return hash;
3894} 3892}
3895 3893
3896 3894
@@ -4445,7 +4443,8 @@ sweep_weak_hash_tables ()
4445 + (unsigned)(Y)) 4443 + (unsigned)(Y))
4446 4444
4447 4445
4448/* Return a hash for string PTR which has length LEN. */ 4446/* Return a hash for string PTR which has length LEN. The hash
4447 code returned is guaranteed to fit in a Lisp integer. */
4449 4448
4450static unsigned 4449static unsigned
4451sxhash_string (ptr, len) 4450sxhash_string (ptr, len)
@@ -4465,7 +4464,7 @@ sxhash_string (ptr, len)
4465 hash = ((hash << 3) + (hash >> 28) + c); 4464 hash = ((hash << 3) + (hash >> 28) + c);
4466 } 4465 }
4467 4466
4468 return hash & 07777777777; 4467 return hash & VALMASK;
4469} 4468}
4470 4469
4471 4470