From 17af43ca76692c7e889c91d3fa9e6690349f0d57 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 21 Feb 2017 15:31:29 -0800 Subject: [PATCH] Minor weak hash table performance tweaks * src/fns.c (make_hash_table): Omit unnecessary assignment to h->next_weak when the hash table is not weak. (copy_hash_table): Put the copy next to the original in the weak_hash_tables list, as this should have better locality when scanning the weak hash tables. --- src/fns.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/fns.c b/src/fns.c index 9668c885ab6..0b694529c52 100644 --- a/src/fns.c +++ b/src/fns.c @@ -3756,9 +3756,7 @@ make_hash_table (struct hash_table_test test, EMACS_INT size, eassert (XHASH_TABLE (table) == h); /* Maybe add this hash table to the list of all weak hash tables. */ - if (NILP (h->weak)) - h->next_weak = NULL; - else + if (! NILP (weak)) { h->next_weak = weak_hash_tables; weak_hash_tables = h; @@ -3788,8 +3786,8 @@ copy_hash_table (struct Lisp_Hash_Table *h1) /* Maybe add this hash table to the list of all weak hash tables. */ if (!NILP (h2->weak)) { - h2->next_weak = weak_hash_tables; - weak_hash_tables = h2; + h2->next_weak = h1->next_weak; + h1->next_weak = h2; } return table; -- 2.39.5