- (values (member t nil)))
- (without-gcing
- ;; We need to rehash here so that a current key can be found if it
- ;; exists.
- (cond ((= (get-header-data (hash-table-table hash-table))
- sb!vm:vector-must-rehash-subtype)
- (rehash-without-growing hash-table))
- ((not (zerop (hash-table-needing-rehash hash-table)))
- (flush-needing-rehash hash-table)))
-
- ;; Search for key in the hash table.
- (multiple-value-bind (hashing eq-based)
- (funcall (hash-table-hash-fun hash-table) key)
- (declare (type hash hashing))
- (let* ((index-vector (hash-table-index-vector hash-table))
- (length (length index-vector))
- (index (rem hashing length))
- (next (aref index-vector index))
- (table (hash-table-table hash-table))
- (next-vector (hash-table-next-vector hash-table))
- (hash-vector (hash-table-hash-vector hash-table))
- (test-fun (hash-table-test-fun hash-table)))
- (declare (type index index next))
- (cond ((zerop next)
- nil)
- ((if (or eq-based (not hash-vector))
- (eq key (aref table (* 2 next)))
- (and (= hashing (aref hash-vector next))
- (funcall test-fun key (aref table (* 2 next)))))
-
- ;; FIXME: Substantially the same block of code seems to
- ;; appear in all three cases. (In the first case, it
- ;; appear bare; in the other two cases, it's wrapped in
- ;; DO.) It should be defined in a separate (possibly
- ;; inline) DEFUN or FLET.
-
- ;; Mark slot as empty.
- (setf (aref table (* 2 next)) +empty-ht-slot+
- (aref table (1+ (* 2 next))) +empty-ht-slot+)
- ;; Update the index-vector pointer.
- (setf (aref index-vector index) (aref next-vector next))
- ;; Push KV slot onto free chain.
- (setf (aref next-vector next)
- (hash-table-next-free-kv hash-table))
- (setf (hash-table-next-free-kv hash-table) next)
- (when hash-vector
- (setf (aref hash-vector next) #x80000000))
- (decf (hash-table-number-entries hash-table))
- t)
- ;; Search next-vector chain for a matching key.
- ((or eq-based (not hash-vector))
- ;; EQ based
- (do ((prior next next)
- (next (aref next-vector next) (aref next-vector next)))
- ((zerop next) nil)
- (declare (type index next))
- (when (eq key (aref table (* 2 next)))
- ;; Mark slot as empty.
- (setf (aref table (* 2 next)) +empty-ht-slot+
- (aref table (1+ (* 2 next))) +empty-ht-slot+)
- ;; Update the prior pointer in the chain to skip this.
- (setf (aref next-vector prior) (aref next-vector next))
- ;; Push KV slot onto free chain.
- (setf (aref next-vector next)
- (hash-table-next-free-kv hash-table))
- (setf (hash-table-next-free-kv hash-table) next)
- (when hash-vector
- (setf (aref hash-vector next) #x80000000))
- (decf (hash-table-number-entries hash-table))
- (return t))))
- (t
- ;; not EQ based
- (do ((prior next next)
- (next (aref next-vector next) (aref next-vector next)))
- ((zerop next) nil)
- (declare (type index next))
- (when (and (= hashing (aref hash-vector next))
- (funcall test-fun key (aref table (* 2 next))))
- ;; Mark slot as empty.
- (setf (aref table (* 2 next)) +empty-ht-slot+)
- (setf (aref table (1+ (* 2 next))) +empty-ht-slot+)
- ;; Update the prior pointer in the chain to skip this.
- (setf (aref next-vector prior) (aref next-vector next))
- ;; Push KV slot onto free chain.
- (setf (aref next-vector next)
- (hash-table-next-free-kv hash-table))
- (setf (hash-table-next-free-kv hash-table) next)
- (when hash-vector
- (setf (aref hash-vector next) #x80000000))
- (decf (hash-table-number-entries hash-table))
- (return t)))))))))