{
Lisp_Object block_name = HASH_KEY (ht, i);
if (!EQ (block_name, Qentry)
- && !BASE_EQ (block_name, Qunbound))
+ && !hash_unused_entry_key_p (block_name))
declare_block (block_name);
}
for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (ht); i++)
{
Lisp_Object block_name = HASH_KEY (ht, i);
- if (!BASE_EQ (block_name, Qunbound))
+ if (!hash_unused_entry_key_p (block_name))
{
Lisp_Object block = HASH_VALUE (ht, i);
Lisp_Object insns = CALL1I (comp-block-insns, block);
struct Lisp_Hash_Table *func_h =
XHASH_TABLE (CALL1I (comp-ctxt-funcs-h, Vcomp_ctxt));
for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (func_h); i++)
- if (!BASE_EQ (HASH_KEY (func_h, i), Qunbound))
+ if (!hash_unused_entry_key_p (HASH_KEY (func_h, i)))
declare_function (HASH_VALUE (func_h, i));
/* Compile all functions. Can't be done before because the
relocation structs has to be already defined. */
for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (func_h); i++)
- if (!BASE_EQ (HASH_KEY (func_h, i), Qunbound))
+ if (!hash_unused_entry_key_p (HASH_KEY (func_h, i)))
compile_function (HASH_VALUE (func_h, i));
/* Work around bug#46495 (GCC PR99126). */
{
Lisp_Object k = HASH_KEY (h, i);
- if (!BASE_EQ (k, Qunbound))
+ if (!hash_unused_entry_key_p (k))
{
Lisp_Object gstring = HASH_VALUE (h, i);
reference that's identical to some global reference. */
for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (h); ++i)
{
- if (!BASE_EQ (HASH_KEY (h, i), Qunbound)
+ if (!hash_unused_entry_key_p (HASH_KEY (h, i))
&& &XMODULE_GLOBAL_REFERENCE (HASH_VALUE (h, i))->value == v)
return true;
}
h->rehash_threshold = rehash_threshold;
h->rehash_size = rehash_size;
h->count = 0;
- h->key_and_value = make_vector (2 * size, Qunbound);
+ h->key_and_value = make_vector (2 * size, HASH_UNUSED_ENTRY_KEY);
h->hash = make_nil_vector (size);
h->next = make_vector (size, make_fixnum (-1));
h->index = make_vector (hash_index_size (h, size), make_fixnum (-1));
Lisp_Object key_and_value
= alloc_larger_vector (h->key_and_value, 2 * new_size);
for (ptrdiff_t i = 2 * old_size; i < 2 * new_size; i++)
- ASET (key_and_value, i, Qunbound);
+ ASET (key_and_value, i, HASH_UNUSED_ENTRY_KEY);
Lisp_Object hash = alloc_larger_vector (h->hash, new_size);
memclear (XVECTOR (hash)->contents + old_size,
/* Store key/value in the key_and_value vector. */
ptrdiff_t i = h->next_free;
eassert (NILP (HASH_HASH (h, i)));
- eassert (BASE_EQ (Qunbound, (HASH_KEY (h, i))));
+ eassert (hash_unused_entry_key_p (HASH_KEY (h, i)));
h->next_free = HASH_NEXT (h, i);
set_hash_key_slot (h, i, key);
set_hash_value_slot (h, i, value);
/* Clear slots in key_and_value and add the slots to
the free list. */
- set_hash_key_slot (h, i, Qunbound);
+ 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_next_slot (h, i, h->next_free);
for (ptrdiff_t i = 0; i < size; i++)
{
set_hash_next_slot (h, i, i < size - 1 ? i + 1 : -1);
- set_hash_key_slot (h, i, Qunbound);
+ set_hash_key_slot (h, i, HASH_UNUSED_ENTRY_KEY);
set_hash_value_slot (h, i, Qnil);
}
h->next_free = i;
/* Clear key, value, and hash. */
- set_hash_key_slot (h, i, Qunbound);
+ set_hash_key_slot (h, i, HASH_UNUSED_ENTRY_KEY);
set_hash_value_slot (h, i, Qnil);
if (!NILP (h->hash))
set_hash_hash_slot (h, i, Qnil);
for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (h); ++i)
{
Lisp_Object k = HASH_KEY (h, i);
- if (!BASE_EQ (k, Qunbound))
+ if (!hash_unused_entry_key_p (k))
call2 (function, k, HASH_VALUE (h, i));
}
for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (h); ++i)
{
Lisp_Object key = HASH_KEY (h, i);
- if (!BASE_EQ (key, Qunbound))
+ if (!hash_unused_entry_key_p (key))
{
CHECK_STRING (key);
Lisp_Object ekey = json_encode (key);
/* Vector of keys and values. The key of item I is found at index
2 * I, the value is found at index 2 * I + 1.
- If the key is equal to Qunbound, then this slot is unused.
+ If the key is HASH_UNUSED_ENTRY_KEY, then this slot is unused.
This is gc_marked specially if the table is weak. */
Lisp_Object key_and_value;
/* Sanity-check pseudovector layout. */
verify (offsetof (struct Lisp_Hash_Table, weak) == header_size);
+/* Key value that marks an unused hash table entry. */
+#define HASH_UNUSED_ENTRY_KEY Qunbound
+
+/* KEY is a key of an unused hash table entry. */
+INLINE bool
+hash_unused_entry_key_p (Lisp_Object key)
+{
+ return BASE_EQ (key, HASH_UNUSED_ENTRY_KEY);
+}
+
INLINE bool
HASH_TABLE_P (Lisp_Object a)
{
else /* if (type == hash_table) */
{
while (idx < HASH_TABLE_SIZE (XHASH_TABLE (collection))
- && BASE_EQ (HASH_KEY (XHASH_TABLE (collection), idx),
- Qunbound))
+ && hash_unused_entry_key_p (HASH_KEY (XHASH_TABLE (collection),
+ idx)))
idx++;
if (idx >= HASH_TABLE_SIZE (XHASH_TABLE (collection)))
break;
else /* if (type == 3) */
{
while (idx < HASH_TABLE_SIZE (XHASH_TABLE (collection))
- && BASE_EQ (HASH_KEY (XHASH_TABLE (collection), idx),
- Qunbound))
+ && hash_unused_entry_key_p (HASH_KEY (XHASH_TABLE (collection),
+ idx)))
idx++;
if (idx >= HASH_TABLE_SIZE (XHASH_TABLE (collection)))
break;
for (i = 0; i < HASH_TABLE_SIZE (h); ++i)
{
tem = HASH_KEY (h, i);
- if (BASE_EQ (tem, Qunbound)) continue;
+ if (hash_unused_entry_key_p (tem)) continue;
Lisp_Object strkey = (SYMBOLP (tem) ? Fsymbol_name (tem) : tem);
if (!STRINGP (strkey)) continue;
if (BASE_EQ (Fcompare_strings (string, Qnil, Qnil,
for (i = 0; i < HASH_TABLE_SIZE (h); ++i)
{
Lisp_Object key = HASH_KEY (h, i);
- if (!BASE_EQ (key, Qunbound)
+ if (!hash_unused_entry_key_p (key)
&& EQ (HASH_VALUE (h, i), Qt))
Fremhash (key, Vprint_number_table);
}
{
Lisp_Object key;
ptrdiff_t idx = e->u.hash.idx;
- while (BASE_EQ ((key = HASH_KEY (h, idx)), Qunbound))
+ while (hash_unused_entry_key_p ((key = HASH_KEY (h, idx))))
idx++;
e->u.hash.idx = idx;
obj = key;