aboutsummaryrefslogtreecommitdiffstats
path: root/src/fns.c
diff options
context:
space:
mode:
authorPaul Eggert2020-01-07 11:23:11 -0800
committerPaul Eggert2020-01-07 11:29:41 -0800
commitf950b078a6f2fd011312e9471998edf6b5fb957e (patch)
treeb26243166a063e13787f19cdad5daf8864b7a151 /src/fns.c
parent72f54f035dc74a01c1ab5ff444752a994d852490 (diff)
downloademacs-f950b078a6f2fd011312e9471998edf6b5fb957e.tar.gz
emacs-f950b078a6f2fd011312e9471998edf6b5fb957e.zip
Help the compiler inline sxhash
* src/fns.c (sxhash_obj): Rename from sxhash and make it static, so that the compiler can inline it better. (sxhash): New function that does not take a depth arg. All callers changed.
Diffstat (limited to 'src/fns.c')
-rw-r--r--src/fns.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/fns.c b/src/fns.c
index 3b5feace521..4a0a8fd96d8 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -47,6 +47,7 @@ static void sort_vector_copy (Lisp_Object, ptrdiff_t,
47enum equal_kind { EQUAL_NO_QUIT, EQUAL_PLAIN, EQUAL_INCLUDING_PROPERTIES }; 47enum equal_kind { EQUAL_NO_QUIT, EQUAL_PLAIN, EQUAL_INCLUDING_PROPERTIES };
48static bool internal_equal (Lisp_Object, Lisp_Object, 48static bool internal_equal (Lisp_Object, Lisp_Object,
49 enum equal_kind, int, Lisp_Object); 49 enum equal_kind, int, Lisp_Object);
50static EMACS_UINT sxhash_obj (Lisp_Object, int);
50 51
51DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0, 52DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0,
52 doc: /* Return the ARGUMENT unchanged. */ 53 doc: /* Return the ARGUMENT unchanged. */
@@ -4022,7 +4023,7 @@ hashfn_eq (Lisp_Object key, struct Lisp_Hash_Table *h)
4022Lisp_Object 4023Lisp_Object
4023hashfn_equal (Lisp_Object key, struct Lisp_Hash_Table *h) 4024hashfn_equal (Lisp_Object key, struct Lisp_Hash_Table *h)
4024{ 4025{
4025 return make_ufixnum (sxhash (key, 0)); 4026 return make_ufixnum (sxhash (key));
4026} 4027}
4027 4028
4028/* Ignore HT and return a hash code for KEY which uses 'eql' to compare keys. 4029/* Ignore HT and return a hash code for KEY which uses 'eql' to compare keys.
@@ -4042,7 +4043,7 @@ hashfn_user_defined (Lisp_Object key, struct Lisp_Hash_Table *h)
4042{ 4043{
4043 Lisp_Object args[] = { h->test.user_hash_function, key }; 4044 Lisp_Object args[] = { h->test.user_hash_function, key };
4044 Lisp_Object hash = hash_table_user_defined_call (ARRAYELTS (args), args, h); 4045 Lisp_Object hash = hash_table_user_defined_call (ARRAYELTS (args), args, h);
4045 return FIXNUMP (hash) ? hash : make_ufixnum (sxhash (hash, 0)); 4046 return FIXNUMP (hash) ? hash : make_ufixnum (sxhash (hash));
4046} 4047}
4047 4048
4048struct hash_table_test const 4049struct hash_table_test const
@@ -4606,13 +4607,13 @@ sxhash_list (Lisp_Object list, int depth)
4606 CONSP (list) && i < SXHASH_MAX_LEN; 4607 CONSP (list) && i < SXHASH_MAX_LEN;
4607 list = XCDR (list), ++i) 4608 list = XCDR (list), ++i)
4608 { 4609 {
4609 EMACS_UINT hash2 = sxhash (XCAR (list), depth + 1); 4610 EMACS_UINT hash2 = sxhash_obj (XCAR (list), depth + 1);
4610 hash = sxhash_combine (hash, hash2); 4611 hash = sxhash_combine (hash, hash2);
4611 } 4612 }
4612 4613
4613 if (!NILP (list)) 4614 if (!NILP (list))
4614 { 4615 {
4615 EMACS_UINT hash2 = sxhash (list, depth + 1); 4616 EMACS_UINT hash2 = sxhash_obj (list, depth + 1);
4616 hash = sxhash_combine (hash, hash2); 4617 hash = sxhash_combine (hash, hash2);
4617 } 4618 }
4618 4619
@@ -4632,7 +4633,7 @@ sxhash_vector (Lisp_Object vec, int depth)
4632 n = min (SXHASH_MAX_LEN, hash & PSEUDOVECTOR_FLAG ? PVSIZE (vec) : hash); 4633 n = min (SXHASH_MAX_LEN, hash & PSEUDOVECTOR_FLAG ? PVSIZE (vec) : hash);
4633 for (i = 0; i < n; ++i) 4634 for (i = 0; i < n; ++i)
4634 { 4635 {
4635 EMACS_UINT hash2 = sxhash (AREF (vec, i), depth + 1); 4636 EMACS_UINT hash2 = sxhash_obj (AREF (vec, i), depth + 1);
4636 hash = sxhash_combine (hash, hash2); 4637 hash = sxhash_combine (hash, hash2);
4637 } 4638 }
4638 4639
@@ -4675,7 +4676,13 @@ sxhash_bignum (Lisp_Object bignum)
4675 structure. Value is an unsigned integer clipped to INTMASK. */ 4676 structure. Value is an unsigned integer clipped to INTMASK. */
4676 4677
4677EMACS_UINT 4678EMACS_UINT
4678sxhash (Lisp_Object obj, int depth) 4679sxhash (Lisp_Object obj)
4680{
4681 return sxhash_obj (obj, 0);
4682}
4683
4684static EMACS_UINT
4685sxhash_obj (Lisp_Object obj, int depth)
4679{ 4686{
4680 EMACS_UINT hash; 4687 EMACS_UINT hash;
4681 4688