Minor fixes
parent
173efd801a
commit
56f292f61b
|
@ -12,7 +12,7 @@ TUPLE: tombstone ;
|
|||
: hash@ ( key keys -- n )
|
||||
>r hashcode r> length 2 /i rem 2 * ; inline
|
||||
|
||||
: probe ( heys i -- hash i ) 2 + over length mod ; inline
|
||||
: probe ( keys i -- hash i ) 2 + over length mod ; inline
|
||||
|
||||
: (key@) ( key keys i -- n )
|
||||
3dup swap nth-unsafe {
|
||||
|
@ -226,19 +226,14 @@ M: hashtable = ( obj hash -- ? )
|
|||
{ [ t ] [ hashtable= ] }
|
||||
} cond ;
|
||||
|
||||
: hashtable-hashcode ( n hashtable -- n )
|
||||
>r 1- r> 0 swap [
|
||||
>r >r
|
||||
over r> hashcode* bitxor
|
||||
over r> hashcode* -1 shift bitxor
|
||||
] hash-each nip ;
|
||||
|
||||
M: hashtable hashcode* ( n hash -- n )
|
||||
dup hash-size 1 number=
|
||||
[ hashtable-hashcode ] [ nip hash-size ] if ;
|
||||
: hashtable-hashcode ( hashtable -- n )
|
||||
0 swap [
|
||||
hashcode >r hashcode -1 shift r> bitxor bitxor
|
||||
] hash-each ;
|
||||
|
||||
M: hashtable hashcode ( hash -- n )
|
||||
2 swap hashcode* ;
|
||||
dup hash-size 1 number=
|
||||
[ hashtable-hashcode ] [ hash-size ] if ;
|
||||
|
||||
: ?hash ( key hash/f -- value/f )
|
||||
dup [ hash ] [ 2drop f ] if ;
|
||||
|
|
|
@ -127,7 +127,7 @@ M: object like drop ;
|
|||
: last/first ( seq -- pair ) dup peek swap first 2array ;
|
||||
|
||||
: sequence= ( seq seq -- ? )
|
||||
2dup [ length ] 2apply = [
|
||||
2dup [ length ] 2apply number= [
|
||||
dup length [ >r 2dup r> 2nth-unsafe = ] all? 2nip
|
||||
] [
|
||||
2drop f
|
||||
|
@ -142,9 +142,8 @@ M: sequence = ( obj seq -- ? )
|
|||
over type over type eq? [ sequence= ] [ 2drop f ] if
|
||||
] if ;
|
||||
|
||||
M: sequence hashcode ( seq -- n )
|
||||
#! Poor
|
||||
length ;
|
||||
M: sequence hashcode ( hash -- n )
|
||||
dup empty? [ drop 0 ] [ first hashcode ] if ;
|
||||
|
||||
IN: kernel
|
||||
|
||||
|
|
|
@ -10,9 +10,6 @@ USING: generic kernel-internals math math-internals ;
|
|||
GENERIC: hashcode ( obj -- n )
|
||||
M: object hashcode drop 0 ;
|
||||
|
||||
GENERIC: hashcode* ( n obj -- n )
|
||||
M: object hashcode* nip hashcode ;
|
||||
|
||||
GENERIC: = ( obj obj -- ? )
|
||||
M: object = eq? ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue