 : hash-deleted+ ( hash -- )
     dup hash-deleted 1+ swap set-hash-deleted ; inline
 
-: (set-hash) ( value key hash -- )
+: (set-hash) ( value key hash -- new? )
     2dup new-key@
-    [ rot hash-count+ ] [ rot drop ] if
-    set-nth-pair ; inline
+    [ rot hash-count+ set-nth-pair t ]
+    [ rot drop set-nth-pair f ] if ; inline
 
 : find-pair-next >r 2 fixnum+fast r> ; inline
 

: find-pair ( array quot -- key value ? ) 0 rot (find-pair) ; inline

: (rehash) ( hash array -- )
    [ swap pick (set-hash) f ] find-pair 2drop 2drop ;

: hash-large? ( hash -- ? )
    dup hash-count 1 fixnum+fast 3 fixnum*fast
    swap hash-array array-capacity > ;

: hash-stale? ( hash -- ? )

    (rehash) ;

M: hashtable set-at ( value key hash -- )
    dup >r (set-hash) [ r> ?grow-hash ] [ r> drop ] if ;

: associate ( value key -- hash )
    2 <hashtable> [ set-at ] keep ;
