This avoids any extra allocation for such vectors, including empty
tables read by the Lisp reader, and provides extra safety essentially
for free.
* src/fns.c (make_hash_table): Allow tables to be 0-sized. The index
will always have at least one entry, to avoid extra look-up costs.
* src/alloc.c (process_mark_stack): Don't mark pure objects,
because empty vectors are pure.
eassert (h->next_weak == NULL);
h->next_weak = weak_hash_tables;
weak_hash_tables = h;
- set_vector_marked (XVECTOR (h->key_and_value));
+ if (!PURE_P (h->key_and_value))
+ set_vector_marked (XVECTOR (h->key_and_value));
}
break;
}
eassert (SYMBOLP (test.name));
eassert (0 <= size && size <= MOST_POSITIVE_FIXNUM);
- if (size == 0)
- size = 1;
-
/* Allocate a table and initialize it. */
h = allocate_hash_table ();
/* Set up the free list. */
for (i = 0; i < size - 1; ++i)
set_hash_next_slot (h, i, i + 1);
- h->next_free = 0;
+ if (size > 0)
+ set_hash_next_slot (h, size - 1, -1);
+ h->next_free = size > 0 ? 0 : -1;
XSET_HASH_TABLE (table, h);
eassert (HASH_TABLE_P (table));
INLINE ptrdiff_t
HASH_TABLE_SIZE (const struct Lisp_Hash_Table *h)
{
- ptrdiff_t size = ASIZE (h->next);
- eassume (0 < size);
- return size;
+ return ASIZE (h->next);
}
/* Compute hash value for KEY in hash table H. */