From: Mattias EngdegÄrd Date: Sun, 29 Oct 2023 10:57:06 +0000 (+0100) Subject: Store hash values as integers instead of Lisp_Object X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a3ae5653cfe1ab2b3eb4c77ce729844ad442b562;p=emacs.git Store hash values as integers instead of Lisp_Object This improves typing, saves pointless tagging and untagging, and prepares for further changes. The new typedef hash_hash_t is an alias for EMACS_UINT, and hash values are still limited to the fixnum range. We now use hash_unused instead of Qnil to mark unused entries. * src/lisp.h (hash_hash_t): New typedef for EMACS_UINT. (hash_unused): New constant. (struct hash_table_test): `hashfn` now returns hash_hash_t. All callers and implementations changed. (struct Lisp_Hash_Table): Retype hash vector to an array of hash_hash_t. All code using it changed accordingly. (HASH_HASH, hash_from_key): * src/fns.c (set_hash_index_slot, hash_index_index) (hash_lookup_with_hash, hash_lookup_get_hash, hash_put): (hash_lookup, hash_put): Retype hash value arguments and return values. All callers adapted. --- diff --git a/src/category.c b/src/category.c index 583cdb3eebb..e7fbf1ff500 100644 --- a/src/category.c +++ b/src/category.c @@ -53,7 +53,7 @@ hash_get_category_set (Lisp_Object table, Lisp_Object category_set) (table, 1, make_hash_table (hashtest_equal, DEFAULT_HASH_SIZE, Weak_None, false)); struct Lisp_Hash_Table *h = XHASH_TABLE (XCHAR_TABLE (table)->extras[1]); - Lisp_Object hash; + hash_hash_t hash; ptrdiff_t i = hash_lookup (h, category_set, &hash); if (i >= 0) return HASH_KEY (h, i); diff --git a/src/charset.c b/src/charset.c index 3aa105e57bd..add3bf846f8 100644 --- a/src/charset.c +++ b/src/charset.c @@ -850,7 +850,6 @@ usage: (define-charset-internal ...) */) /* Charset attr vector. */ Lisp_Object attrs; Lisp_Object val; - Lisp_Object hash_code; struct Lisp_Hash_Table *hash_table = XHASH_TABLE (Vcharset_hash_table); int i, j; struct charset charset; @@ -1108,6 +1107,7 @@ usage: (define-charset-internal ...) */) CHECK_LIST (args[charset_arg_plist]); ASET (attrs, charset_plist, args[charset_arg_plist]); + hash_hash_t hash_code; charset.hash_index = hash_lookup (hash_table, args[charset_arg_name], &hash_code); if (charset.hash_index >= 0) diff --git a/src/composite.c b/src/composite.c index ed1aeb380a0..bd69a953e3f 100644 --- a/src/composite.c +++ b/src/composite.c @@ -166,7 +166,7 @@ ptrdiff_t get_composition_id (ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t nchars, Lisp_Object prop, Lisp_Object string) { - Lisp_Object id, length, components, key, *key_contents, hash_code; + Lisp_Object id, length, components, key, *key_contents; ptrdiff_t glyph_len; struct Lisp_Hash_Table *hash_table = XHASH_TABLE (composition_hash_table); ptrdiff_t hash_index; @@ -240,6 +240,7 @@ get_composition_id (ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t nchars, else goto invalid_composition; + hash_hash_t hash_code; hash_index = hash_lookup (hash_table, key, &hash_code); if (hash_index >= 0) { @@ -653,7 +654,7 @@ composition_gstring_put_cache (Lisp_Object gstring, ptrdiff_t len) { struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table); Lisp_Object header = LGSTRING_HEADER (gstring); - Lisp_Object hash = hash_from_key (h, header); + EMACS_UINT hash = hash_from_key (h, header); if (len < 0) { ptrdiff_t glyph_len = LGSTRING_GLYPH_LEN (gstring); diff --git a/src/emacs-module.c b/src/emacs-module.c index 60aed68f2cd..728da8c2882 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c @@ -427,7 +427,8 @@ module_make_global_ref (emacs_env *env, emacs_value value) { MODULE_FUNCTION_BEGIN (NULL); struct Lisp_Hash_Table *h = XHASH_TABLE (Vmodule_refs_hash); - Lisp_Object new_obj = value_to_lisp (value), hashcode; + Lisp_Object new_obj = value_to_lisp (value); + hash_hash_t hashcode; ptrdiff_t i = hash_lookup (h, new_obj, &hashcode); /* Note: This approach requires the garbage collector to never move diff --git a/src/fns.c b/src/fns.c index 3aca588a8a5..5a3c51c8412 100644 --- a/src/fns.c +++ b/src/fns.c @@ -2759,7 +2759,7 @@ internal_equal (Lisp_Object o1, Lisp_Object o2, enum equal_kind equal_kind, case Lisp_Cons: case Lisp_Vectorlike: { struct Lisp_Hash_Table *h = XHASH_TABLE (ht); - Lisp_Object hash; + hash_hash_t hash; ptrdiff_t i = hash_lookup (h, o1, &hash); if (i >= 0) { /* `o1' was seen already. */ @@ -4279,7 +4279,7 @@ set_hash_next_slot (struct Lisp_Hash_Table *h, ptrdiff_t idx, ptrdiff_t val) h->next[idx] = val; } static void -set_hash_hash_slot (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) +set_hash_hash_slot (struct Lisp_Hash_Table *h, ptrdiff_t idx, hash_hash_t val) { eassert (idx >= 0 && idx < h->table_size); h->hash[idx] = val; @@ -4450,41 +4450,42 @@ cmpfn_user_defined (Lisp_Object key1, Lisp_Object key2, /* Ignore H and return a hash code for KEY which uses 'eq' to compare keys. */ -static Lisp_Object +static hash_hash_t hashfn_eq (Lisp_Object key, struct Lisp_Hash_Table *h) { if (symbols_with_pos_enabled && SYMBOL_WITH_POS_P (key)) key = SYMBOL_WITH_POS_SYM (key); - return make_ufixnum (XHASH (key) ^ XTYPE (key)); + return XHASH (key) ^ XTYPE (key); } /* Ignore H and return a hash code for KEY which uses 'equal' to compare keys. The hash code is at most INTMASK. */ -static Lisp_Object +static hash_hash_t hashfn_equal (Lisp_Object key, struct Lisp_Hash_Table *h) { - return make_ufixnum (sxhash (key)); + return sxhash (key); } /* Ignore H and return a hash code for KEY which uses 'eql' to compare keys. The hash code is at most INTMASK. */ -static Lisp_Object +static hash_hash_t hashfn_eql (Lisp_Object key, struct Lisp_Hash_Table *h) { - return (FLOATP (key) || BIGNUMP (key) ? hashfn_equal : hashfn_eq) (key, h); + return (FLOATP (key) || BIGNUMP (key) + ? hashfn_equal (key, h) : hashfn_eq (key, h)); } /* Given H, return a hash code for KEY which uses a user-defined function to compare keys. */ -static Lisp_Object +static hash_hash_t hashfn_user_defined (Lisp_Object key, struct Lisp_Hash_Table *h) { Lisp_Object args[] = { h->test.user_hash_function, key }; Lisp_Object hash = hash_table_user_defined_call (ARRAYELTS (args), args, h); - return FIXNUMP (hash) ? hash : make_ufixnum (sxhash (hash)); + return FIXNUMP (hash) ? XUFIXNUM(hash) : sxhash (hash); } struct hash_table_test const @@ -4584,7 +4585,8 @@ make_hash_table (struct hash_table_test test, EMACS_INT size, h->key_and_value[i] = HASH_UNUSED_ENTRY_KEY; h->hash = hash_table_alloc_bytes (size * sizeof *h->hash); - memclear (h->hash, size * sizeof *h->hash); + for (ptrdiff_t i = 0; i < size; i++) + h->hash[i] = hash_unused; h->next = hash_table_alloc_bytes (size * sizeof *h->next); for (ptrdiff_t i = 0; i < size - 1; i++) @@ -4650,10 +4652,10 @@ copy_hash_table (struct Lisp_Hash_Table *h1) /* Compute index into the index vector from a hash value. */ static inline ptrdiff_t -hash_index_index (struct Lisp_Hash_Table *h, Lisp_Object hash_code) +hash_index_index (struct Lisp_Hash_Table *h, hash_hash_t hash) { eassert (h->index_size > 0); - return XUFIXNUM (hash_code) % h->index_size; + return hash % h->index_size; } /* Resize hash table H if it's too full. If H cannot be resized @@ -4690,9 +4692,10 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h) for (ptrdiff_t i = 2 * old_size; i < 2 * new_size; i++) key_and_value[i] = HASH_UNUSED_ENTRY_KEY; - Lisp_Object *hash = hash_table_alloc_bytes (new_size * sizeof *hash); + hash_hash_t *hash = hash_table_alloc_bytes (new_size * sizeof *hash); memcpy (hash, h->hash, old_size * sizeof *hash); - memclear (hash + old_size, (new_size - old_size) * word_size); + for (ptrdiff_t i = old_size; i < new_size; i++) + hash[i] = hash_unused; ptrdiff_t old_index_size = h->index_size; ptrdiff_t index_size = hash_index_size (new_size); @@ -4723,7 +4726,7 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h) /* Rehash: all data occupy entries 0..old_size-1. */ for (ptrdiff_t i = 0; i < old_size; i++) { - Lisp_Object hash_code = HASH_HASH (h, i); + hash_hash_t hash_code = HASH_HASH (h, i); ptrdiff_t start_of_bucket = hash_index_index (h, hash_code); set_hash_next_slot (h, i, HASH_INDEX (h, start_of_bucket)); set_hash_index_slot (h, start_of_bucket, i); @@ -4764,7 +4767,8 @@ hash_table_thaw (Lisp_Object hash_table) h->next_free = -1; h->hash = hash_table_alloc_bytes (size * sizeof *h->hash); - memclear (h->hash, size * sizeof *h->hash); + for (ptrdiff_t i = 0; i < size; i++) + h->hash[i] = hash_unused; h->next = hash_table_alloc_bytes (size * sizeof *h->next); for (ptrdiff_t i = 0; i < size; i++) @@ -4779,7 +4783,7 @@ hash_table_thaw (Lisp_Object hash_table) for (ptrdiff_t i = 0; i < size; i++) { Lisp_Object key = HASH_KEY (h, i); - Lisp_Object hash_code = hash_from_key (h, key); + hash_hash_t hash_code = hash_from_key (h, key); ptrdiff_t start_of_bucket = hash_index_index (h, hash_code); set_hash_hash_slot (h, i, hash_code); set_hash_next_slot (h, i, HASH_INDEX (h, start_of_bucket)); @@ -4792,9 +4796,9 @@ hash_table_thaw (Lisp_Object hash_table) matching KEY, or -1 if not found. */ ptrdiff_t -hash_lookup (struct Lisp_Hash_Table *h, Lisp_Object key, Lisp_Object *hash) +hash_lookup (struct Lisp_Hash_Table *h, Lisp_Object key, hash_hash_t *hash) { - Lisp_Object hash_code = hash_from_key (h, key); + hash_hash_t hash_code = hash_from_key (h, key); if (hash) *hash = hash_code; @@ -4803,7 +4807,7 @@ hash_lookup (struct Lisp_Hash_Table *h, Lisp_Object key, Lisp_Object *hash) for (i = HASH_INDEX (h, start_of_bucket); 0 <= i; i = HASH_NEXT (h, i)) if (EQ (key, HASH_KEY (h, i)) || (h->test.cmpfn - && EQ (hash_code, HASH_HASH (h, i)) + && hash_code == HASH_HASH (h, i) && !NILP (h->test.cmpfn (key, HASH_KEY (h, i), h)))) break; @@ -4824,7 +4828,7 @@ check_mutable_hash_table (Lisp_Object obj, struct Lisp_Hash_Table *h) ptrdiff_t hash_put (struct Lisp_Hash_Table *h, Lisp_Object key, Lisp_Object value, - Lisp_Object hash) + hash_hash_t hash) { /* Increment count after resizing because resizing may fail. */ maybe_resize_hash_table (h); @@ -4832,7 +4836,7 @@ hash_put (struct Lisp_Hash_Table *h, Lisp_Object key, Lisp_Object value, /* Store key/value in the key_and_value vector. */ ptrdiff_t i = h->next_free; - eassert (NILP (HASH_HASH (h, i))); + eassert (HASH_HASH (h, i) == hash_unused); eassert (hash_unused_entry_key_p (HASH_KEY (h, i))); h->next_free = HASH_NEXT (h, i); set_hash_key_slot (h, i, key); @@ -4854,8 +4858,8 @@ hash_put (struct Lisp_Hash_Table *h, Lisp_Object key, Lisp_Object value, void hash_remove_from_table (struct Lisp_Hash_Table *h, Lisp_Object key) { - Lisp_Object hash_code = hash_from_key (h, key); - ptrdiff_t start_of_bucket = hash_index_index (h, hash_code); + hash_hash_t hashval = hash_from_key (h, key); + ptrdiff_t start_of_bucket = hash_index_index (h, hashval); ptrdiff_t prev = -1; for (ptrdiff_t i = HASH_INDEX (h, start_of_bucket); @@ -4864,7 +4868,7 @@ hash_remove_from_table (struct Lisp_Hash_Table *h, Lisp_Object key) { if (EQ (key, HASH_KEY (h, i)) || (h->test.cmpfn - && EQ (hash_code, HASH_HASH (h, i)) + && hashval == HASH_HASH (h, i) && !NILP (h->test.cmpfn (key, HASH_KEY (h, i), h)))) { /* Take entry out of collision chain. */ @@ -4877,7 +4881,7 @@ hash_remove_from_table (struct Lisp_Hash_Table *h, Lisp_Object key) the free list. */ set_hash_key_slot (h, i, HASH_UNUSED_ENTRY_KEY); set_hash_value_slot (h, i, Qnil); - set_hash_hash_slot (h, i, Qnil); + set_hash_hash_slot (h, i, hash_unused); set_hash_next_slot (h, i, h->next_free); h->next_free = i; h->count--; @@ -4898,9 +4902,9 @@ hash_clear (struct Lisp_Hash_Table *h) if (h->count > 0) { ptrdiff_t size = HASH_TABLE_SIZE (h); - memclear (h->hash, size * word_size); for (ptrdiff_t i = 0; i < size; i++) { + set_hash_hash_slot (h, i, hash_unused); set_hash_next_slot (h, i, i < size - 1 ? i + 1 : -1); set_hash_key_slot (h, i, HASH_UNUSED_ENTRY_KEY); set_hash_value_slot (h, i, Qnil); @@ -4983,7 +4987,7 @@ sweep_weak_table (struct Lisp_Hash_Table *h, bool remove_entries_p) /* Clear key, value, and hash. */ set_hash_key_slot (h, i, HASH_UNUSED_ENTRY_KEY); set_hash_value_slot (h, i, Qnil); - set_hash_hash_slot (h, i, Qnil); + set_hash_hash_slot (h, i, hash_unused); eassert (h->count != 0); h->count--; @@ -5269,7 +5273,7 @@ If (eq A B), then (= (sxhash-eq A) (sxhash-eq B)). Hash codes are not guaranteed to be preserved across Emacs sessions. */) (Lisp_Object obj) { - return hashfn_eq (obj, NULL); + return make_ufixnum (hashfn_eq (obj, NULL)); } DEFUN ("sxhash-eql", Fsxhash_eql, Ssxhash_eql, 1, 1, 0, @@ -5280,7 +5284,7 @@ isn't necessarily true. Hash codes are not guaranteed to be preserved across Emacs sessions. */) (Lisp_Object obj) { - return hashfn_eql (obj, NULL); + return make_ufixnum (hashfn_eql (obj, NULL)); } DEFUN ("sxhash-equal", Fsxhash_equal, Ssxhash_equal, 1, 1, 0, @@ -5291,7 +5295,7 @@ opposite isn't necessarily true. Hash codes are not guaranteed to be preserved across Emacs sessions. */) (Lisp_Object obj) { - return hashfn_equal (obj, NULL); + return make_ufixnum (hashfn_equal (obj, NULL)); } DEFUN ("sxhash-equal-including-properties", Fsxhash_equal_including_properties, @@ -5315,7 +5319,7 @@ Hash codes are not guaranteed to be preserved across Emacs sessions. */) sxhash (CDR (collector))))); } - return hashfn_equal (obj, NULL); + return make_ufixnum (hashfn_equal (obj, NULL)); } DEFUN ("make-hash-table", Fmake_hash_table, Smake_hash_table, 0, MANY, 0, @@ -5549,7 +5553,7 @@ VALUE. In any case, return VALUE. */) struct Lisp_Hash_Table *h = check_hash_table (table); check_mutable_hash_table (table, h); - Lisp_Object hash; + EMACS_UINT hash; ptrdiff_t i = hash_lookup (h, key, &hash); if (i >= 0) set_hash_value_slot (h, i, value); @@ -5650,7 +5654,7 @@ Internal use only. */) { Lisp_Object bucket = Qnil; for (ptrdiff_t j = HASH_INDEX (h, i); j != -1; j = HASH_NEXT (h, j)) - bucket = Fcons (Fcons (HASH_KEY (h, j), HASH_HASH (h, j)), + bucket = Fcons (Fcons (HASH_KEY (h, j), make_int (HASH_HASH (h, j))), bucket); if (!NILP (bucket)) ret = Fcons (Fnreverse (bucket), ret); diff --git a/src/image.c b/src/image.c index 9c100213590..55b027d568b 100644 --- a/src/image.c +++ b/src/image.c @@ -6079,8 +6079,9 @@ xpm_put_color_table_h (Lisp_Object color_table, Lisp_Object color) { struct Lisp_Hash_Table *table = XHASH_TABLE (color_table); - Lisp_Object chars = make_unibyte_string (chars_start, chars_len), hash_code; + Lisp_Object chars = make_unibyte_string (chars_start, chars_len); + hash_hash_t hash_code; hash_lookup (table, chars, &hash_code); hash_put (table, chars, color, hash_code); } diff --git a/src/json.c b/src/json.c index d98b312ecc9..1bea4baa8ba 100644 --- a/src/json.c +++ b/src/json.c @@ -879,7 +879,8 @@ json_to_lisp (json_t *json, const struct json_configuration *conf) json_t *value; json_object_foreach (json, key_str, value) { - Lisp_Object key = build_string_from_utf8 (key_str), hash; + Lisp_Object key = build_string_from_utf8 (key_str); + hash_hash_t hash; ptrdiff_t i = hash_lookup (h, key, &hash); /* Keys in JSON objects are unique, so the key can't be present yet. */ diff --git a/src/lisp.h b/src/lisp.h index dd457392cca..474498094c9 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2385,6 +2385,10 @@ INLINE int struct Lisp_Hash_Table; +/* The type of a hash value stored in the table. + It's unsigned and a subtype of EMACS_UINT. */ +typedef EMACS_UINT hash_hash_t; + typedef enum { Test_eql, Test_eq, @@ -2406,7 +2410,7 @@ struct hash_table_test Lisp_Object (*cmpfn) (Lisp_Object, Lisp_Object, struct Lisp_Hash_Table *); /* C function to compute hash code. */ - Lisp_Object (*hashfn) (Lisp_Object, struct Lisp_Hash_Table *); + hash_hash_t (*hashfn) (Lisp_Object, struct Lisp_Hash_Table *); }; typedef enum { @@ -2421,6 +2425,11 @@ typedef enum { both key and value remain. */ } hash_table_weakness_t; +/* An value that marks an unused hash entry. + Any hash_hash_t value that is not a valid fixnum will do here. */ +enum { hash_unused = (hash_hash_t)MOST_POSITIVE_FIXNUM + 1 }; +verify (FIXNUM_OVERFLOW_P (hash_unused)); + struct Lisp_Hash_Table { union vectorlike_header header; @@ -2462,9 +2471,9 @@ struct Lisp_Hash_Table ptrdiff_t table_size; /* Size of the next and hash vectors. */ - /* Vector of hash codes. Each entry is either a fixnum, or nil if unused. + /* Vector of hash codes. The value hash_unused marks an unused table entry. This vector is table_size entries long. */ - Lisp_Object *hash; + hash_hash_t *hash; /* Vector used to chain entries. If entry I is free, next[I] is the entry number of the next free item. If entry I is non-free, @@ -2553,7 +2562,7 @@ HASH_VALUE (const struct Lisp_Hash_Table *h, ptrdiff_t idx) } /* Value is the hash code computed for entry IDX in hash table H. */ -INLINE Lisp_Object +INLINE hash_hash_t HASH_HASH (const struct Lisp_Hash_Table *h, ptrdiff_t idx) { eassert (idx >= 0 && idx < h->table_size); @@ -2567,8 +2576,8 @@ HASH_TABLE_SIZE (const struct Lisp_Hash_Table *h) return h->table_size; } -/* Compute hash value for KEY in hash table H. */ -INLINE Lisp_Object +/* Hash value for KEY in hash table H. */ +INLINE hash_hash_t hash_from_key (struct Lisp_Hash_Table *h, Lisp_Object key) { return h->test.hashfn (key, h); @@ -4054,9 +4063,9 @@ EMACS_UINT sxhash (Lisp_Object); Lisp_Object make_hash_table (struct hash_table_test, EMACS_INT, hash_table_weakness_t, bool); Lisp_Object hash_table_weakness_symbol (hash_table_weakness_t weak); -ptrdiff_t hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object *); +ptrdiff_t hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, hash_hash_t *); ptrdiff_t hash_put (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object, - Lisp_Object); + hash_hash_t); void hash_remove_from_table (struct Lisp_Hash_Table *, Lisp_Object); extern struct hash_table_test const hashtest_eq, hashtest_eql, hashtest_equal; extern void validate_subarray (Lisp_Object, Lisp_Object, Lisp_Object, diff --git a/src/lread.c b/src/lread.c index 284536fc81f..9ad4d35c0c2 100644 --- a/src/lread.c +++ b/src/lread.c @@ -4255,7 +4255,7 @@ read0 (Lisp_Object readcharfun, bool locate_syms) struct Lisp_Hash_Table *h = XHASH_TABLE (read_objects_map); Lisp_Object number = make_fixnum (n); - Lisp_Object hash; + hash_hash_t hash; ptrdiff_t i = hash_lookup (h, number, &hash); if (i >= 0) /* Not normal, but input could be malformed. */ @@ -4571,7 +4571,7 @@ read0 (Lisp_Object readcharfun, bool locate_syms) struct Lisp_Hash_Table *h2 = XHASH_TABLE (read_objects_completed); - Lisp_Object hash; + hash_hash_t hash; ptrdiff_t i = hash_lookup (h2, placeholder, &hash); eassert (i < 0); hash_put (h2, placeholder, Qnil, hash); @@ -4586,7 +4586,7 @@ read0 (Lisp_Object readcharfun, bool locate_syms) { struct Lisp_Hash_Table *h2 = XHASH_TABLE (read_objects_completed); - Lisp_Object hash; + hash_hash_t hash; ptrdiff_t i = hash_lookup (h2, obj, &hash); eassert (i < 0); hash_put (h2, obj, Qnil, hash); @@ -4598,7 +4598,7 @@ read0 (Lisp_Object readcharfun, bool locate_syms) /* ...and #n# will use the real value from now on. */ struct Lisp_Hash_Table *h = XHASH_TABLE (read_objects_map); - Lisp_Object hash; + hash_hash_t hash; ptrdiff_t i = hash_lookup (h, e->u.numbered.number, &hash); eassert (i >= 0); set_hash_value_slot (h, i, obj); diff --git a/src/macfont.m b/src/macfont.m index 8aba440d196..dcaa85bea05 100644 --- a/src/macfont.m +++ b/src/macfont.m @@ -980,7 +980,7 @@ macfont_invalidate_family_cache (void) ptrdiff_t i, size = HASH_TABLE_SIZE (h); for (i = 0; i < size; ++i) - if (!NILP (HASH_HASH (h, i))) + if (HASH_HASH (h, i) != hash_unused) { Lisp_Object value = HASH_VALUE (h, i); @@ -1017,12 +1017,13 @@ macfont_set_family_cache (Lisp_Object symbol, CFStringRef string) { struct Lisp_Hash_Table *h; ptrdiff_t i; - Lisp_Object hash, value; + Lisp_Object value; if (!HASH_TABLE_P (macfont_family_cache)) macfont_family_cache = CALLN (Fmake_hash_table, QCtest, Qeq); h = XHASH_TABLE (macfont_family_cache); + hash_hash_t hash; i = hash_lookup (h, symbol, &hash); value = string ? make_mint_ptr ((void *) CFRetain (string)) : Qnil; if (i >= 0) diff --git a/src/pdumper.c b/src/pdumper.c index 8a93c45e07b..5ed91c668df 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -2661,7 +2661,7 @@ hash_table_contents (struct Lisp_Hash_Table *h) relies on it by expecting hash table indices to stay constant across the dump. */ for (ptrdiff_t i = 0; i < old_size; i++) - if (!NILP (HASH_HASH (h, i))) + if (HASH_HASH (h, i) != hash_unused) { key_and_value[n++] = HASH_KEY (h, i); key_and_value[n++] = HASH_VALUE (h, i);