aboutsummaryrefslogtreecommitdiffstats
path: root/src/lisp.h
diff options
context:
space:
mode:
authorPaul Eggert2019-08-21 18:54:08 -0700
committerPaul Eggert2019-08-21 19:01:49 -0700
commitceebf3efbea7faffc01558d88c91250539c737e0 (patch)
tree3f8d585e220804bd18b493f696691ed7e91fad9f /src/lisp.h
parentc64c0230d65260f44f367bac72bfdee50c52a90d (diff)
downloademacs-ceebf3efbea7faffc01558d88c91250539c737e0.tar.gz
emacs-ceebf3efbea7faffc01558d88c91250539c737e0.zip
Fix clrhash bug when hash table needs rehashing
Problem reported by Pip Cet in: https://lists.gnu.org/r/emacs-devel/2019-08/msg00316.html * src/fns.c (maybe_resize_hash_table): Prefer ASET to gc_aset where either will do. Simplify appending of Qunbound values. Put index_size calculation closer to where it’s needed. (hash_clear): If hash_rehash_needed_p (h), don’t clear the nonexistent hash vector. Use memclear to speed up clearing. * src/lisp.h (HASH_TABLE_SIZE): Check that the size is positive, and tell that to the compiler.
Diffstat (limited to 'src/lisp.h')
-rw-r--r--src/lisp.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lisp.h b/src/lisp.h
index 56ad99b8e39..ae5a81e7b5e 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2307,7 +2307,7 @@ struct Lisp_Hash_Table
2307 weakness of the table. */ 2307 weakness of the table. */
2308 Lisp_Object weak; 2308 Lisp_Object weak;
2309 2309
2310 /* Vector of hash codes. 2310 /* Vector of hash codes, or nil if the table needs rehashing.
2311 If the I-th entry is unused, then hash[I] should be nil. */ 2311 If the I-th entry is unused, then hash[I] should be nil. */
2312 Lisp_Object hash; 2312 Lisp_Object hash;
2313 2313
@@ -2327,8 +2327,7 @@ struct Lisp_Hash_Table
2327 'index' are special and are either ignored by the GC or traced in 2327 'index' are special and are either ignored by the GC or traced in
2328 a special way (e.g. because of weakness). */ 2328 a special way (e.g. because of weakness). */
2329 2329
2330 /* Number of key/value entries in the table. This number is 2330 /* Number of key/value entries in the table. */
2331 negated if the table needs rehashing. */
2332 ptrdiff_t count; 2331 ptrdiff_t count;
2333 2332
2334 /* Index of first free entry in free list, or -1 if none. */ 2333 /* Index of first free entry in free list, or -1 if none. */
@@ -2413,7 +2412,9 @@ HASH_HASH (const struct Lisp_Hash_Table *h, ptrdiff_t idx)
2413INLINE ptrdiff_t 2412INLINE ptrdiff_t
2414HASH_TABLE_SIZE (const struct Lisp_Hash_Table *h) 2413HASH_TABLE_SIZE (const struct Lisp_Hash_Table *h)
2415{ 2414{
2416 return ASIZE (h->next); 2415 ptrdiff_t size = ASIZE (h->next);
2416 eassume (0 < size);
2417 return size;
2417} 2418}
2418 2419
2419void hash_table_rehash (struct Lisp_Hash_Table *h); 2420void hash_table_rehash (struct Lisp_Hash_Table *h);