[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 53132c1 6/7: pdumper speed tweeks for hash tables
From: |
Paul Eggert |
Subject: |
master 53132c1 6/7: pdumper speed tweeks for hash tables |
Date: |
Tue, 11 Aug 2020 05:27:52 -0400 (EDT) |
branch: master
commit 53132c1639beb2fc8687d88a6e17fffa4216b440
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>
pdumper speed tweeks for hash tables
* src/pdumper.c (dump_queue_empty_p): Avoid unnecessary call
to Fhash_table_count on a known hash table.
(dump_hash_table_list): !NILP, not CONSP.
(hash_table_freeze, hash_table_thaw): ASIZE, not Flength, on vectors.
Initialize in same order as struct.
(hash_table_thaw): make_nil_vector, not Fmake_vector with nil.
---
src/pdumper.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/src/pdumper.c b/src/pdumper.c
index fcad524..bc9d197 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -964,11 +964,9 @@ dump_queue_init (struct dump_queue *dump_queue)
static bool
dump_queue_empty_p (struct dump_queue *dump_queue)
{
- bool is_empty =
- EQ (Fhash_table_count (dump_queue->sequence_numbers),
- make_fixnum (0));
- eassert (EQ (Fhash_table_count (dump_queue->sequence_numbers),
- Fhash_table_count (dump_queue->link_weights)));
+ ptrdiff_t count = XHASH_TABLE (dump_queue->sequence_numbers)->count;
+ bool is_empty = count == 0;
+ eassert (count == XFIXNAT (Fhash_table_count (dump_queue->link_weights)));
if (!is_empty)
{
eassert (!dump_tailq_empty_p (&dump_queue->zero_weight_objects)
@@ -2643,7 +2641,7 @@ hash_table_contents (struct Lisp_Hash_Table *h)
static dump_off
dump_hash_table_list (struct dump_context *ctx)
{
- if (CONSP (ctx->hash_tables))
+ if (!NILP (ctx->hash_tables))
return dump_object (ctx, CALLN (Fapply, Qvector, ctx->hash_tables));
else
return 0;
@@ -2652,20 +2650,20 @@ dump_hash_table_list (struct dump_context *ctx)
static void
hash_table_freeze (struct Lisp_Hash_Table *h)
{
- ptrdiff_t nkeys = XFIXNAT (Flength (h->key_and_value)) / 2;
+ ptrdiff_t npairs = ASIZE (h->key_and_value) / 2;
h->key_and_value = hash_table_contents (h);
- h->next_free = (nkeys == h->count ? -1 : h->count);
- h->index = Flength (h->index);
- h->next = h->hash = make_fixnum (nkeys);
+ h->next = h->hash = make_fixnum (npairs);
+ h->index = make_fixnum (ASIZE (h->index));
+ h->next_free = (npairs == h->count ? -1 : h->count);
}
static void
hash_table_thaw (Lisp_Object hash)
{
struct Lisp_Hash_Table *h = XHASH_TABLE (hash);
- h->index = Fmake_vector (h->index, make_fixnum (-1));
- h->hash = Fmake_vector (h->hash, Qnil);
+ h->hash = make_nil_vector (XFIXNUM (h->hash));
h->next = Fmake_vector (h->next, make_fixnum (-1));
+ h->index = Fmake_vector (h->index, make_fixnum (-1));
hash_table_rehash (hash);
}
- master updated (0d0aad2 -> 25b4168), Paul Eggert, 2020/08/11
- master 53132c1 6/7: pdumper speed tweeks for hash tables,
Paul Eggert <=
- master 23c1d5d 2/7: * src/fns.c (hash_table_rehash): Help the compiler a bit., Paul Eggert, 2020/08/11
- 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