[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 25b4168 7/7: pdumper avoid listing hash table contents
From: |
Paul Eggert |
Subject: |
master 25b4168 7/7: pdumper avoid listing hash table contents |
Date: |
Tue, 11 Aug 2020 05:27:52 -0400 (EDT) |
branch: master
commit 25b416888847db26fa6de2e64d628851a275e10c
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>
pdumper avoid listing hash table contents
* src/pdumper.c (hash_table_contents): Create a vector directly,
instead of creating a list and then converting that to a vector.
---
src/pdumper.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/src/pdumper.c b/src/pdumper.c
index bc9d197..94921dc 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -2617,25 +2617,28 @@ hash_table_contents (struct Lisp_Hash_Table *h)
{
if (h->test.hashfn == hashfn_user_defined)
error ("cannot dump hash tables with user-defined tests"); /* Bug#36769 */
- Lisp_Object contents = Qnil;
+
+ ptrdiff_t size = HASH_TABLE_SIZE (h);
+ Lisp_Object key_and_value = make_uninit_vector (2 * size);
+ ptrdiff_t n = 0;
/* Make sure key_and_value ends up in the same order; charset.c
relies on it by expecting hash table indices to stay constant
across the dump. */
- for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (h) - h->count; i++)
- {
- dump_push (&contents, Qnil);
- dump_push (&contents, Qunbound);
- }
-
- for (ptrdiff_t i = HASH_TABLE_SIZE (h) - 1; i >= 0; --i)
+ for (ptrdiff_t i = 0; i < size; i++)
if (!NILP (HASH_HASH (h, i)))
{
- dump_push (&contents, HASH_VALUE (h, i));
- dump_push (&contents, HASH_KEY (h, i));
+ ASET (key_and_value, n++, HASH_KEY (h, i));
+ ASET (key_and_value, n++, HASH_VALUE (h, i));
}
- return CALLN (Fapply, Qvector, contents);
+ while (n < 2 * size)
+ {
+ ASET (key_and_value, n++, Qunbound);
+ ASET (key_and_value, n++, Qnil);
+ }
+
+ return key_and_value;
}
static dump_off
- 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, 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 <=
- master 5bd7b3c 3/7: * src/pdumper.c (pdumper_load): XSETVECTOR -> make_lisp_ptr., Paul Eggert, 2020/08/11