Remove redundant stack shuffling from hashtable implementation

release
Slava Pestov 2007-10-04 18:45:06 -04:00
parent 0183a40717
commit 849c83247d
2 changed files with 4 additions and 5 deletions

View File

@ -70,7 +70,7 @@ HELP: nth-pair
{ nth-pair set-nth-pair } related-words
HELP: set-nth-pair
{ $values { "value" "the second element of the pair" } { "key" "the first element of the pair" } { "n" "an index in the sequence" } { "seq" "a sequence" } }
{ $values { "value" "the second element of the pair" } { "key" "the first element of the pair" } { "seq" "a sequence" } { "n" "an index in the sequence" } }
{ $description "Stores a pair of values into the elements with index " { $snippet "n" } " and " { $snippet "n+1" } ", respectively." }
{ $warning "This word is in the " { $vocab-link "hashtables.private" } " vocabulary because it does not perform bounds checks." }
{ $side-effects "seq" } ;

View File

@ -59,8 +59,7 @@ IN: hashtables
swap 2 fixnum+fast 2dup slot -rot 1 fixnum+fast slot ;
inline
: set-nth-pair ( value key n seq -- )
swap
: set-nth-pair ( value key seq n -- )
2 fixnum+fast [ set-slot ] 2keep
1 fixnum+fast set-slot ; inline
@ -73,7 +72,7 @@ IN: hashtables
: (set-hash) ( value key hash -- )
2dup new-key@
[ rot hash-count+ ] [ rot drop ] if
swap set-nth-pair ; inline
set-nth-pair ; inline
: find-pair-next >r 2 fixnum+fast r> ; inline
@ -133,7 +132,7 @@ M: hashtable clear-assoc ( hash -- )
M: hashtable delete-at ( key hash -- )
tuck key@ [
>r >r ((tombstone)) dup r> r> swap set-nth-pair
>r >r ((tombstone)) dup r> r> set-nth-pair
hash-deleted+
] [
3drop