Comment 2 for bug 1729471

Douglas Katzman (dougk) wrote :

different example as of commit 42ab54187 (which is after that one):

(declaim (inline to-boolean))
(defun to-boolean (x) (/= x 0))

(declaim (inline newfoo))
(defun newfoo (storage key converter)
  (labels ((value (entry) (funcall converter (ash entry -17)))
           (insert (start key value)
             (loop for link from 0 below 8
                   for index = start then (next index)
                   for entry = (aref storage index)
                   when (= key (logand entry #xff))
                   do (return-from insert (and value (value entry))))
             value)
           (probe (index)
             (let ((entry (aref storage index)))
               (when (= key (logand #xff entry))
                 (return-from newfoo (value entry))))))
    (declare (inline value))
    (probe 0)
    (multiple-value-bind (new value) (make-new-frob)
      (declare (ignore new))
      (insert (logand (sxhash key) 15) key value))))

(defun %access-cache (storage key)
  (newfoo storage key #'to-boolean))