h->key_and_value[i] = HASH_UNUSED_ENTRY_KEY;
h->hash = hash_table_alloc_bytes (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++)
hash_hash_t *hash = hash_table_alloc_bytes (new_size * sizeof *hash);
memcpy (hash, h->hash, old_size * sizeof *hash);
- 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);
h->next_free = -1;
h->hash = hash_table_alloc_bytes (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++)
hash_put (struct Lisp_Hash_Table *h, Lisp_Object key, Lisp_Object value,
hash_hash_t hash)
{
- eassert (!BASE_EQ (key, Qunbound));
+ eassert (!hash_unused_entry_key_p (key));
/* Increment count after resizing because resizing may fail. */
maybe_resize_hash_table (h);
h->count++;
/* Store key/value in the key_and_value vector. */
ptrdiff_t i = h->next_free;
- 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);
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, hash_unused);
set_hash_next_slot (h, i, h->next_free);
h->next_free = i;
h->count--;
ptrdiff_t size = HASH_TABLE_SIZE (h);
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);
set_hash_next_slot (h, i, h->next_free);
h->next_free = i;
- /* Clear key, value, and hash. */
+ /* Clear key and value. */
set_hash_key_slot (h, i, HASH_UNUSED_ENTRY_KEY);
set_hash_value_slot (h, i, Qnil);
- set_hash_hash_slot (h, i, hash_unused);
eassert (h->count != 0);
h->count--;
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));
-
/* The type of a hash table index, both for table indices and index
(hash) indices. It's signed and a subtype of ptrdiff_t. */
typedef int32_t hash_idx_t;
Otherwise it is heap-allocated. */
hash_idx_t *index;
- /* Vector of hash codes. The value hash_unused marks an unused table entry.
+ /* Vector of hash codes. Unused entries have undefined values.
This vector is table_size entries long. */
hash_hash_t *hash;
relies on it by expecting hash table indices to stay constant
across the dump. */
for (ptrdiff_t i = 0; i < old_size; i++)
- if (HASH_HASH (h, i) != hash_unused)
- {
- key_and_value[n++] = HASH_KEY (h, i);
- key_and_value[n++] = HASH_VALUE (h, i);
- }
+ {
+ Lisp_Object key = HASH_KEY (h, i);
+ if (!hash_unused_entry_key_p (key))
+ {
+ key_and_value[n++] = key;
+ key_and_value[n++] = HASH_VALUE (h, i);
+ }
+ }
return key_and_value;
}