wyhash


Vocabulary
checksums.wyhash

Definition


Methods

M:: wyhash checksum-bytes ( bytes checksum -- value )
checksum seed>> P0 bitxor
:> seed! bytes length :> len len 16 <= [
len 8 <= [
len 4 >= [
bytes [ 4 head-slice ] [ 4 tail-slice* ] bi
[ le> ] bi@
] [
len 0 > [
0 bytes nth 16 shift len 2/ bytes nth
8 shift bitor len 1 - bytes nth bitor 0
] [ 0 0 ] if
] if
] [
bytes [ 8 head-slice ] [ 8 tail-slice* ] bi
[ le> ] bi@
] if
] [
len 1 - dup 48 mod - :> len/48 len 1 - dup 16 mod -
:> len/16 0 len/48 bytes uint64_t native-mapper [
seed :> see1! seed :> see2! 6 <groups> [
6 firstn-unsafe :> ( n0 n1 n2 n3 n4 n5 ) n0 P1
bitxor n1 seed bitxor wymix seed! n2 P2 bitxor
n3 see1 bitxor wymix see1! n4 P3 bitxor
n5 see2 bitxor wymix see2!
] each see1 see2 bitxor seed bitxor seed!
] unless-empty
len/48 len/16 bytes uint64_t native-mapper [
2 <groups> [
first2-unsafe :> ( n0 n1 ) n0 P1 bitxor
n1 seed bitxor wymix seed!
] each
] unless-empty len 16 - len bytes uint64_t native-mapper
first2
] if :> ( a b ) len P1 bitxor a P1 bitxor b seed bitxor
wymix wymix ;