[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 23c1d5d 2/7: * src/fns.c (hash_table_rehash): Help the compiler a
From: |
Paul Eggert |
Subject: |
master 23c1d5d 2/7: * src/fns.c (hash_table_rehash): Help the compiler a bit. |
Date: |
Tue, 11 Aug 2020 05:27:51 -0400 (EDT) |
branch: master
commit 23c1d5dff99f1c5d502096be4584c786c55e9262
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>
* src/fns.c (hash_table_rehash): Help the compiler a bit.
---
src/fns.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/fns.c b/src/fns.c
index 41e2610..9199178 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -4250,14 +4250,16 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h)
Normally there's never a need to recompute hashes.
This is done only on first access to a hash-table loaded from
the "pdump", because the objects' addresses may have changed, thus
- affecting their hash. */
+ affecting their hashes. */
void
hash_table_rehash (Lisp_Object hash)
{
struct Lisp_Hash_Table *h = XHASH_TABLE (hash);
+ ptrdiff_t i, count = h->count;
+
/* Recompute the actual hash codes for each entry in the table.
Order is still invalid. */
- for (ptrdiff_t i = 0; i < h->count; ++i)
+ for (i = 0; i < count; i++)
{
Lisp_Object key = HASH_KEY (h, i);
Lisp_Object hash_code = h->test.hashfn (key, h);
@@ -4268,7 +4270,8 @@ hash_table_rehash (Lisp_Object hash)
eassert (HASH_NEXT (h, i) != i); /* Stop loops. */
}
- for (ptrdiff_t i = h->count; i < ASIZE (h->next) - 1; i++)
+ ptrdiff_t size = ASIZE (h->next);
+ for (; i + 1 < size; i++)
set_hash_next_slot (h, i, i + 1);
}
@@ -4892,7 +4895,6 @@ DEFUN ("hash-table-count", Fhash_table_count,
Shash_table_count, 1, 1, 0,
(Lisp_Object table)
{
struct Lisp_Hash_Table *h = check_hash_table (table);
-
return make_fixnum (h->count);
}
- master updated (0d0aad2 -> 25b4168), Paul Eggert, 2020/08/11
- master 53132c1 6/7: pdumper speed tweeks for hash tables, Paul Eggert, 2020/08/11
- master 23c1d5d 2/7: * src/fns.c (hash_table_rehash): Help the compiler a bit.,
Paul Eggert <=
- master 16a1664 1/7: Rehash hash tables eagerly after loading a dump, Paul Eggert, 2020/08/11
- master eeaef1a 4/7: Don’t needlessly convert to ‘unsigned’ in pdumper, Paul Eggert, 2020/08/11
- master 9e4e477 5/7: In pdumper, simplify INT_MAX computation, Paul Eggert, 2020/08/11
- master 25b4168 7/7: pdumper avoid listing hash table contents, Paul Eggert, 2020/08/11
- master 5bd7b3c 3/7: * src/pdumper.c (pdumper_load): XSETVECTOR -> make_lisp_ptr., Paul Eggert, 2020/08/11