Subject: Re: bug#36597: 27.0.50; rehash hash tables eagerly in pdumper

From: Paul Eggert <[email-masked]>
Date: Tue, 11 Aug 2020 10:31:24 -0700

On 8/11/20 10:00 AM, Eli Zaretskii wrote:
>> I suggest going back to Fmake_vector (h->hash, Qnil), as in the
>> attached patch. It's shorter, and it actually compiles.
> Yes, I did that, thanks.

The compilation issue was due to pdumper enabling -Wconversion, which causes 
more trouble than it cures (but that is a different topic). I worked around the 
glitch by installing the attached further patch, which should also help explain 
the motivation for make_nil_vector.
>From 669aeafbd14b0ebb824bacba0a6b3daad30847a9 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Tue, 11 Aug 2020 10:29:02 -0700
Subject: [PATCH] Prefer make_nil_vector to make-vector with nil

* src/pdumper.c (hash_table_thaw): Pacify -Wconversion so
we can use make_nil_vector again.
* src/timefns.c (syms_of_timefns): Prefer make_nil_vector
to make_vector with Qnil.
---
 src/lisp.h    | 3 ++-
 src/pdumper.c | 4 +++-
 src/timefns.c | 2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/lisp.h b/src/lisp.h
index d88038d91b..2962babb4f 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3947,7 +3947,8 @@ make_uninit_sub_char_table (int depth, int min_char)
   return v;
 }
 
-/* Make a vector of SIZE nils.  */
+/* Make a vector of SIZE nils - faster than make_vector (size, Qnil)
+   if the OS already cleared the new memory.  */
 
 INLINE Lisp_Object
 make_nil_vector (ptrdiff_t size)
diff --git a/src/pdumper.c b/src/pdumper.c
index 6c581bcd0b..aaa760d70d 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -2664,7 +2664,9 @@ hash_table_freeze (struct Lisp_Hash_Table *h)
 hash_table_thaw (Lisp_Object hash)
 {
   struct Lisp_Hash_Table *h = XHASH_TABLE (hash);
-  h->hash = Fmake_vector (h->hash, Qnil);
+  ALLOW_IMPLICIT_CONVERSION;
+  h->hash = make_nil_vector (XFIXNUM (h->hash));
+  DISALLOW_IMPLICIT_CONVERSION;
   h->next = Fmake_vector (h->next, make_fixnum (-1));
   h->index = Fmake_vector (h->index, make_fixnum (-1));
 
diff --git a/src/timefns.c b/src/timefns.c
index 7bcc37d7c1..94cfddf0da 100644
--- a/src/timefns.c
+++ b/src/timefns.c
@@ -2048,7 +2048,7 @@ syms_of_timefns (void)
   defsubr (&Scurrent_time_zone);
   defsubr (&Sset_time_zone_rule);
 
-  flt_radix_power = make_vector (flt_radix_power_size, Qnil);
+  flt_radix_power = make_nil_vector (flt_radix_power_size);
   staticpro (&flt_radix_power);
 
 #ifdef NEED_ZTRILLION_INIT
-- 
2.17.1