diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2017-02-21 15:31:29 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2017-02-21 15:39:17 -0800 |
commit | 5cbdaa98f975c870c4afa24346630a18b55f27ab (patch) | |
tree | b0a776c467e6b1d53fd1e2837305fbc512803df7 /src/lisp.h | |
parent | 7207b63c8e290ddec33908ce8d38be5793388318 (diff) | |
download | emacs-5cbdaa98f975c870c4afa24346630a18b55f27ab.tar.gz emacs-5cbdaa98f975c870c4afa24346630a18b55f27ab.tar.bz2 emacs-5cbdaa98f975c870c4afa24346630a18b55f27ab.zip |
Use ptrdiff_t instead of Lisp_Object for collision
* src/alloc.c (purecopy_hash_table): Assign, don’t purecopy.
* src/fns.c (set_hash_next_slot, set_hash_index_slot): Hash index
arg is now ptrdiff_t index (or -1 if empty), not Lisp_Object
integer (or Qnil if empty). All callers changed.
(larger_vecalloc): New static function.
(larger_vector): Use it.
(HASH_NEXT, HASH_INDEX): Move here from lisp.h. Return ptrdiff_t
index (or -1) not Lisp_Object integer (or Qnil). All callers changed.
* src/fns.c (make_hash_table, maybe_resize_hash_table, hash_lookup)
(hash_put, hash_remove_from_table, hash_clear, sweep_weak_table):
* src/profiler.c (evict_lower_half, record_backtrace):
-1, not nil, is now the convention for end of collision list.
* src/fns.c (maybe_resize_hash_table): Avoid double-initialization
of the free list. Reallocate H->next last, in case other
reallocations exhaust memory.
* src/lisp.h (struct Lisp_Hash_Table): ‘next_free’ is now
ptrdiff_t, not Lisp_Object. Adjust commentary for ‘next’ and
‘index’, which no longer contain nil.
(HASH_NEXT, HASH_INDEX): Move to src/fns.c.
Diffstat (limited to 'src/lisp.h')
-rw-r--r-- | src/lisp.h | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/src/lisp.h b/src/lisp.h index 6e0252621a6..027fd07d720 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -1980,13 +1980,12 @@ struct Lisp_Hash_Table /* 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, - next[I] is the index of the next entry in the collision chain. */ + next[I] is the index of the next entry in the collision chain, + or -1 if there is such entry. */ Lisp_Object next; - /* Index of first free entry in free list. */ - Lisp_Object next_free; - - /* Bucket vector. A non-nil entry is the index of the first item in + /* 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. This vector's size can be larger than the hash table size to reduce collisions. */ Lisp_Object index; @@ -1998,6 +1997,9 @@ struct Lisp_Hash_Table /* Number of key/value entries in the table. */ ptrdiff_t count; + /* Index of first free entry in free list, or -1 if none. */ + ptrdiff_t next_free; + /* True if the table can be purecopied. The table cannot be changed afterwards. */ bool pure; @@ -2050,14 +2052,6 @@ HASH_VALUE (struct Lisp_Hash_Table *h, ptrdiff_t idx) return AREF (h->key_and_value, 2 * idx + 1); } -/* Value is the index of the next entry following the one at IDX - in hash table H. */ -INLINE Lisp_Object -HASH_NEXT (struct Lisp_Hash_Table *h, ptrdiff_t idx) -{ - return AREF (h->next, idx); -} - /* Value is the hash code computed for entry IDX in hash table H. */ INLINE Lisp_Object HASH_HASH (struct Lisp_Hash_Table *h, ptrdiff_t idx) @@ -2065,14 +2059,6 @@ HASH_HASH (struct Lisp_Hash_Table *h, ptrdiff_t idx) return AREF (h->hash, idx); } -/* Value is the index of the element in hash table H that is the - start of the collision list at index IDX in the index vector of H. */ -INLINE Lisp_Object -HASH_INDEX (struct Lisp_Hash_Table *h, ptrdiff_t idx) -{ - return AREF (h->index, idx); -} - /* Value is the size of hash table H. */ INLINE ptrdiff_t HASH_TABLE_SIZE (struct Lisp_Hash_Table *h) |