]> git.eshelyaron.com Git - emacs.git/commitdiff
Help the compiler inline sxhash
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 7 Jan 2020 19:23:11 +0000 (11:23 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 7 Jan 2020 19:29:41 +0000 (11:29 -0800)
* 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.

src/fns.c
src/image.c
src/lisp.h

index 3b5feace5213c6a51745b75b96e20e6e4581b6ae..4a0a8fd96d8c3ad3ce6be94cc12331a9ba8aaa0d 100644 (file)
--- a/src/fns.c
+++ b/src/fns.c
@@ -47,6 +47,7 @@ static void sort_vector_copy (Lisp_Object, ptrdiff_t,
 enum equal_kind { EQUAL_NO_QUIT, EQUAL_PLAIN, EQUAL_INCLUDING_PROPERTIES };
 static bool internal_equal (Lisp_Object, Lisp_Object,
                            enum equal_kind, int, Lisp_Object);
+static EMACS_UINT sxhash_obj (Lisp_Object, int);
 
 DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0,
        doc: /* Return the ARGUMENT unchanged.  */
@@ -4022,7 +4023,7 @@ hashfn_eq (Lisp_Object key, struct Lisp_Hash_Table *h)
 Lisp_Object
 hashfn_equal (Lisp_Object key, struct Lisp_Hash_Table *h)
 {
-  return make_ufixnum (sxhash (key, 0));
+  return make_ufixnum (sxhash (key));
 }
 
 /* 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)
 {
   Lisp_Object args[] = { h->test.user_hash_function, key };
   Lisp_Object hash = hash_table_user_defined_call (ARRAYELTS (args), args, h);
-  return FIXNUMP (hash) ? hash : make_ufixnum (sxhash (hash, 0));
+  return FIXNUMP (hash) ? hash : make_ufixnum (sxhash (hash));
 }
 
 struct hash_table_test const
@@ -4606,13 +4607,13 @@ sxhash_list (Lisp_Object list, int depth)
         CONSP (list) && i < SXHASH_MAX_LEN;
         list = XCDR (list), ++i)
       {
-       EMACS_UINT hash2 = sxhash (XCAR (list), depth + 1);
+       EMACS_UINT hash2 = sxhash_obj (XCAR (list), depth + 1);
        hash = sxhash_combine (hash, hash2);
       }
 
   if (!NILP (list))
     {
-      EMACS_UINT hash2 = sxhash (list, depth + 1);
+      EMACS_UINT hash2 = sxhash_obj (list, depth + 1);
       hash = sxhash_combine (hash, hash2);
     }
 
@@ -4632,7 +4633,7 @@ sxhash_vector (Lisp_Object vec, int depth)
   n = min (SXHASH_MAX_LEN, hash & PSEUDOVECTOR_FLAG ? PVSIZE (vec) : hash);
   for (i = 0; i < n; ++i)
     {
-      EMACS_UINT hash2 = sxhash (AREF (vec, i), depth + 1);
+      EMACS_UINT hash2 = sxhash_obj (AREF (vec, i), depth + 1);
       hash = sxhash_combine (hash, hash2);
     }
 
@@ -4675,7 +4676,13 @@ sxhash_bignum (Lisp_Object bignum)
    structure.  Value is an unsigned integer clipped to INTMASK.  */
 
 EMACS_UINT
-sxhash (Lisp_Object obj, int depth)
+sxhash (Lisp_Object obj)
+{
+  return sxhash_obj (obj, 0);
+}
+
+static EMACS_UINT
+sxhash_obj (Lisp_Object obj, int depth)
 {
   EMACS_UINT hash;
 
index 5fe0d713e1bd96e0e8b5bf14a4c3a376ca0ae796..b4ce08eeb3c562b1dcf8dab87c14bce838fb5c46 100644 (file)
@@ -1616,7 +1616,7 @@ search_image_cache (struct frame *f, Lisp_Object spec, EMACS_UINT hash)
 static void
 uncache_image (struct frame *f, Lisp_Object spec)
 {
-  struct image *img = search_image_cache (f, spec, sxhash (spec, 0));
+  struct image *img = search_image_cache (f, spec, sxhash (spec));
   if (img)
     {
       free_image (f, img);
@@ -2281,7 +2281,7 @@ lookup_image (struct frame *f, Lisp_Object spec)
   eassert (valid_image_p (spec));
 
   /* Look up SPEC in the hash table of the image cache.  */
-  hash = sxhash (spec, 0);
+  hash = sxhash (spec);
   img = search_image_cache (f, spec, hash);
   if (img && img->load_failed_p)
     {
index e1bbb53ad49a03ef7fe4d2be1dd5a2b70d960115..1a1ae0399be0d49eabec17918363ab8f8257d7c6 100644 (file)
@@ -3652,7 +3652,7 @@ extern bool sweep_weak_table (struct Lisp_Hash_Table *, bool);
 extern void hexbuf_digest (char *, void const *, int);
 extern char *extract_data_from_object (Lisp_Object, ptrdiff_t *, ptrdiff_t *);
 EMACS_UINT hash_string (char const *, ptrdiff_t);
-EMACS_UINT sxhash (Lisp_Object, int);
+EMACS_UINT sxhash (Lisp_Object);
 Lisp_Object hashfn_eql (Lisp_Object, struct Lisp_Hash_Table *);
 Lisp_Object hashfn_equal (Lisp_Object, struct Lisp_Hash_Table *);
 Lisp_Object hashfn_user_defined (Lisp_Object, struct Lisp_Hash_Table *);