Skip to content

Commit f950b07

Browse files
committed
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.
1 parent 72f54f0 commit f950b07

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

src/fns.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static void sort_vector_copy (Lisp_Object, ptrdiff_t,
4747
enum equal_kind { EQUAL_NO_QUIT, EQUAL_PLAIN, EQUAL_INCLUDING_PROPERTIES };
4848
static bool internal_equal (Lisp_Object, Lisp_Object,
4949
enum equal_kind, int, Lisp_Object);
50+
static EMACS_UINT sxhash_obj (Lisp_Object, int);
5051

5152
DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0,
5253
doc: /* Return the ARGUMENT unchanged. */
@@ -4022,7 +4023,7 @@ hashfn_eq (Lisp_Object key, struct Lisp_Hash_Table *h)
40224023
Lisp_Object
40234024
hashfn_equal (Lisp_Object key, struct Lisp_Hash_Table *h)
40244025
{
4025-
return make_ufixnum (sxhash (key, 0));
4026+
return make_ufixnum (sxhash (key));
40264027
}
40274028

40284029
/* 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)
40424043
{
40434044
Lisp_Object args[] = { h->test.user_hash_function, key };
40444045
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));
40464047
}
40474048

40484049
struct hash_table_test const
@@ -4606,13 +4607,13 @@ sxhash_list (Lisp_Object list, int depth)
46064607
CONSP (list) && i < SXHASH_MAX_LEN;
46074608
list = XCDR (list), ++i)
46084609
{
4609-
EMACS_UINT hash2 = sxhash (XCAR (list), depth + 1);
4610+
EMACS_UINT hash2 = sxhash_obj (XCAR (list), depth + 1);
46104611
hash = sxhash_combine (hash, hash2);
46114612
}
46124613

46134614
if (!NILP (list))
46144615
{
4615-
EMACS_UINT hash2 = sxhash (list, depth + 1);
4616+
EMACS_UINT hash2 = sxhash_obj (list, depth + 1);
46164617
hash = sxhash_combine (hash, hash2);
46174618
}
46184619

@@ -4632,7 +4633,7 @@ sxhash_vector (Lisp_Object vec, int depth)
46324633
n = min (SXHASH_MAX_LEN, hash & PSEUDOVECTOR_FLAG ? PVSIZE (vec) : hash);
46334634
for (i = 0; i < n; ++i)
46344635
{
4635-
EMACS_UINT hash2 = sxhash (AREF (vec, i), depth + 1);
4636+
EMACS_UINT hash2 = sxhash_obj (AREF (vec, i), depth + 1);
46364637
hash = sxhash_combine (hash, hash2);
46374638
}
46384639

@@ -4675,7 +4676,13 @@ sxhash_bignum (Lisp_Object bignum)
46754676
structure. Value is an unsigned integer clipped to INTMASK. */
46764677

46774678
EMACS_UINT
4678-
sxhash (Lisp_Object obj, int depth)
4679+
sxhash (Lisp_Object obj)
4680+
{
4681+
return sxhash_obj (obj, 0);
4682+
}
4683+
4684+
static EMACS_UINT
4685+
sxhash_obj (Lisp_Object obj, int depth)
46794686
{
46804687
EMACS_UINT hash;
46814688

src/image.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,7 @@ search_image_cache (struct frame *f, Lisp_Object spec, EMACS_UINT hash)
16161616
static void
16171617
uncache_image (struct frame *f, Lisp_Object spec)
16181618
{
1619-
struct image *img = search_image_cache (f, spec, sxhash (spec, 0));
1619+
struct image *img = search_image_cache (f, spec, sxhash (spec));
16201620
if (img)
16211621
{
16221622
free_image (f, img);
@@ -2281,7 +2281,7 @@ lookup_image (struct frame *f, Lisp_Object spec)
22812281
eassert (valid_image_p (spec));
22822282

22832283
/* Look up SPEC in the hash table of the image cache. */
2284-
hash = sxhash (spec, 0);
2284+
hash = sxhash (spec);
22852285
img = search_image_cache (f, spec, hash);
22862286
if (img && img->load_failed_p)
22872287
{

src/lisp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3652,7 +3652,7 @@ extern bool sweep_weak_table (struct Lisp_Hash_Table *, bool);
36523652
extern void hexbuf_digest (char *, void const *, int);
36533653
extern char *extract_data_from_object (Lisp_Object, ptrdiff_t *, ptrdiff_t *);
36543654
EMACS_UINT hash_string (char const *, ptrdiff_t);
3655-
EMACS_UINT sxhash (Lisp_Object, int);
3655+
EMACS_UINT sxhash (Lisp_Object);
36563656
Lisp_Object hashfn_eql (Lisp_Object, struct Lisp_Hash_Table *);
36573657
Lisp_Object hashfn_equal (Lisp_Object, struct Lisp_Hash_Table *);
36583658
Lisp_Object hashfn_user_defined (Lisp_Object, struct Lisp_Hash_Table *);

0 commit comments

Comments
 (0)