Fix odd hashtable growing behavior

release
Slava Pestov 2007-10-26 03:59:36 -04:00
parent 55ecc4b2bc
commit 5fb227926c
1 changed files with 6 additions and 6 deletions

View File

@ -69,10 +69,10 @@ IN: hashtables
: 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
@ -94,10 +94,10 @@ IN: hashtables
: find-pair ( array quot -- key value ? ) 0 rot (find-pair) ; inline
: (rehash) ( hash array -- )
[ swap pick (set-hash) f ] find-pair 2drop 2drop ;
[ swap pick (set-hash) drop f ] find-pair 2drop 2drop ;
: hash-large? ( hash -- ? )
dup hash-count 1 fixnum+fast 3 fixnum*fast
dup hash-count 3 fixnum*fast
swap hash-array array-capacity > ;
: hash-stale? ( hash -- ? )
@ -149,7 +149,7 @@ M: hashtable assoc-size ( hash -- n )
(rehash) ;
M: hashtable set-at ( value key hash -- )
dup ?grow-hash (set-hash) ;
dup >r (set-hash) [ r> ?grow-hash ] [ r> drop ] if ;
: associate ( value key -- hash )
2 <hashtable> [ set-at ] keep ;