 : set-nth-item ( key seq n -- )
     2 fixnum+fast set-slot ; inline
 
-: (rehash) ( hash seq -- )
-    swap [ dupd new-key@ set-nth-item ] curry each ; inline
+: (adjoin) ( key hash -- )
+    dupd new-key@ set-nth-item ; inline
+
+: (rehash) ( seq hash -- )
+    [ (adjoin) ] curry each ; inline
 
 : hash-large? ( hash -- ? )
     [ count>> 3 fixnum*fast 1 fixnum+fast ]

    over hash-set? [ set= ] [ 2drop f ] if ;

: >hash-set ( members -- hash-set )
    dup length <hash-set> [ [ adjoin ] curry each ] keep ;

M: hash-set set-like
    drop dup hash-set? [ ?members >hash-set ] unless ; inline

    [ count>> ] [ deleted>> ] bi - ; inline

M: hash-set adjoin ( key hash -- )
    dup ?grow-hash (adjoin) ;

<PRIVATE

