mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-11 09:20:51 +00:00
(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.
This commit is contained in:
parent
8c1bec7c1d
commit
cf6818892f
31
src/fns.c
31
src/fns.c
@ -3852,12 +3852,9 @@ hashfn_eq (h, key)
|
|||||||
struct Lisp_Hash_Table *h;
|
struct Lisp_Hash_Table *h;
|
||||||
Lisp_Object key;
|
Lisp_Object key;
|
||||||
{
|
{
|
||||||
/* Lisp strings can change their address. Don't try to compute a
|
unsigned hash = XUINT (key) ^ XGCTYPE (key);
|
||||||
hash code for a string from its address. */
|
xassert ((hash & ~VALMASK) == 0);
|
||||||
if (STRINGP (key))
|
return hash;
|
||||||
return sxhash_string (XSTRING (key)->data, XSTRING (key)->size);
|
|
||||||
else
|
|
||||||
return XUINT (key) ^ XGCTYPE (key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3870,14 +3867,13 @@ hashfn_eql (h, key)
|
|||||||
struct Lisp_Hash_Table *h;
|
struct Lisp_Hash_Table *h;
|
||||||
Lisp_Object key;
|
Lisp_Object key;
|
||||||
{
|
{
|
||||||
/* Lisp strings can change their address. Don't try to compute a
|
unsigned hash;
|
||||||
hash code for a string from its address. */
|
if (FLOATP (key))
|
||||||
if (STRINGP (key))
|
hash = sxhash (key, 0);
|
||||||
return sxhash_string (XSTRING (key)->data, XSTRING (key)->size);
|
|
||||||
else if (FLOATP (key))
|
|
||||||
return sxhash (key, 0);
|
|
||||||
else
|
else
|
||||||
return XUINT (key) ^ XGCTYPE (key);
|
hash = XUINT (key) ^ XGCTYPE (key);
|
||||||
|
xassert ((hash & ~VALMASK) == 0);
|
||||||
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3890,7 +3886,9 @@ hashfn_equal (h, key)
|
|||||||
struct Lisp_Hash_Table *h;
|
struct Lisp_Hash_Table *h;
|
||||||
Lisp_Object key;
|
Lisp_Object key;
|
||||||
{
|
{
|
||||||
return sxhash (key, 0);
|
unsigned hash = sxhash (key, 0);
|
||||||
|
xassert ((hash & ~VALMASK) == 0);
|
||||||
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4445,7 +4443,8 @@ sweep_weak_hash_tables ()
|
|||||||
+ (unsigned)(Y))
|
+ (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
|
static unsigned
|
||||||
sxhash_string (ptr, len)
|
sxhash_string (ptr, len)
|
||||||
@ -4465,7 +4464,7 @@ sxhash_string (ptr, len)
|
|||||||
hash = ((hash << 3) + (hash >> 28) + c);
|
hash = ((hash << 3) + (hash >> 28) + c);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hash & 07777777777;
|
return hash & VALMASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user