/* Constant hash index vector used when the table size is zero.
This avoids allocating it from the heap. */
-static const ptrdiff_t empty_hash_index_vector[] = {-1};
+static const hash_idx_t empty_hash_index_vector[] = {-1};
/* Create and initialize a new hash table.
h->hash = NULL;
h->next = NULL;
eassert (index_size == 1);
- h->index = (ptrdiff_t *)empty_hash_index_vector;
+ h->index = (hash_idx_t *)empty_hash_index_vector;
h->next_free = -1;
}
else
/* Allocate all the new vectors before updating *H, to
avoid problems if memory is exhausted. */
- ptrdiff_t *next = hash_table_alloc_bytes (new_size * sizeof *next);
+ hash_idx_t *next = hash_table_alloc_bytes (new_size * sizeof *next);
for (ptrdiff_t i = old_size; i < new_size - 1; i++)
next[i] = i + 1;
next[new_size - 1] = -1;
ptrdiff_t old_index_size = h->index_size;
ptrdiff_t index_size = hash_index_size (new_size);
- ptrdiff_t *index = hash_table_alloc_bytes (index_size * sizeof *index);
+ hash_idx_t *index = hash_table_alloc_bytes (index_size * sizeof *index);
for (ptrdiff_t i = 0; i < index_size; i++)
index[i] = -1;
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 ptrdiff_t hash_idx_t;
+
struct Lisp_Hash_Table
{
union vectorlike_header header;
The table is physically split into three vectors (hash, next,
key_and_value) which may or may not be beneficial. */
+ hash_idx_t index_size; /* Size of the index vector. */
+ hash_idx_t table_size; /* Size of the next and hash vectors. */
+
/* Bucket vector. An entry of -1 indicates no item is present,
and a nonnegative entry is the index of the first item in
a collision chain.
If index_size is 1 (and table_size is 0), then this is the
constant read-only vector {-1}, shared between all instances.
Otherwise it is heap-allocated. */
- ptrdiff_t *index;
- ptrdiff_t index_size; /* Size of the index vector. */
-
- ptrdiff_t table_size; /* Size of the next and hash vectors. */
+ hash_idx_t *index;
/* Vector of hash codes. The value hash_unused marks an unused table entry.
This vector is table_size entries long. */
next[I] is the index of the next entry in the collision chain,
or -1 if there is no such entry.
This vector is table_size entries long. */
- ptrdiff_t *next;
+ hash_idx_t *next;
/* Number of key/value entries in the table. */
- ptrdiff_t count;
+ hash_idx_t count;
/* Index of first free entry in free list, or -1 if none. */
- ptrdiff_t next_free;
+ hash_idx_t next_free;
/* Weakness of the table. */
hash_table_weakness_t weakness : 8;
dump_tailq_length (&dump_queue->zero_weight_objects),
dump_tailq_length (&dump_queue->one_weight_normal_objects),
dump_tailq_length (&dump_queue->one_weight_strong_objects),
- XHASH_TABLE (dump_queue->link_weights)->count);
+ (ptrdiff_t) XHASH_TABLE (dump_queue->link_weights)->count);
static const int nr_candidates = 3;
struct candidate