Skip to content

Commit

Permalink
Fix (setf gethash) in the fallback solution not returning the new value
Browse files Browse the repository at this point in the history
It would return nil.
  • Loading branch information
metawilm committed Nov 19, 2020
1 parent f269831 commit 7bd02a5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions custom-hash-table.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ Offending form: ~S" loop-form))))
(loop for x-and-val in existing-values
for (x-key . nil) = x-and-val
when (funcall test-fn key x-key)
do (progn (setf (cdr x-and-val) new-val) (return-from gethash))
finally (push (cons key new-val) (gethash key.hash real-ht)))))))
do (progn (setf (cdr x-and-val) new-val)
(return-from gethash new-val))
finally (push (cons key new-val) (gethash key.hash real-ht))
(return new-val))))))

(defun remhash (key ht)
(etypecase ht
Expand Down

0 comments on commit 7bd02a5

Please sign in to comment.