- (and (find-if (lambda (elt)
- (and (typep elt 'layout)
- (zerop (layout-clos-hash elt))))
- (cache-vector cache))
- t))
+ (let ((vector (cache-vector cache))
+ (line-size (cache-line-size cache))
+ (key-count (cache-key-count cache))
+ (mask (cache-mask cache))
+ (index 0))
+ (loop
+ ;; Check if the line is in use, and check validity of the keys.
+ (let ((key1 (svref vector index)))
+ (when (cache-key-p key1)
+ (if (zerop (layout-clos-hash key1))
+ ;; First key invalid.
+ (return-from cache-has-invalid-entries-p t)
+ ;; Line is in use and the first key is valid: check the rest.
+ (loop for offset from 1 below key-count
+ do (let ((thing (svref vector (+ index offset))))
+ (when (or (not (cache-key-p thing))
+ (zerop (layout-clos-hash thing)))
+ ;; Incomplete line or invalid layout.
+ (return-from cache-has-invalid-entries-p t)))))))
+ ;; Line empty of valid, onwards.
+ (setf index (next-cache-index mask index line-size))
+ (when (zerop index)
+ ;; wrapped around
+ (return-from cache-has-invalid-entries-p nil)))))