mirror of
https://github.com/urbit/shrub.git
synced 2025-01-08 06:00:27 +03:00
Add MurmurHash3.
This commit is contained in:
parent
5df088c79a
commit
06fb497dca
@ -1075,6 +1075,33 @@
|
|||||||
:: section 2cD, insecure hashing ::
|
:: section 2cD, insecure hashing ::
|
||||||
::
|
::
|
||||||
++ fnv |=(a=@ (end 5 1 (mul 16.777.619 a))) :: FNV scrambler
|
++ fnv |=(a=@ (end 5 1 (mul 16.777.619 a))) :: FNV scrambler
|
||||||
|
++ mur
|
||||||
|
~/ %mur
|
||||||
|
|= [key=@ syd=@]
|
||||||
|
?> (lte (met 5 syd) 1)
|
||||||
|
=+ ^= row
|
||||||
|
|= [a=@ b=@]
|
||||||
|
(con (end 5 1 (lsh 0 a b)) (rsh 0 (sub 32 a) b))
|
||||||
|
=+ mow=|=([a=@ b=@] (end 5 1 (mul a b)))
|
||||||
|
=+ len=(met 5 key)
|
||||||
|
=- =. goc (mix goc len)
|
||||||
|
=. goc (mix goc (rsh 4 1 goc))
|
||||||
|
=. goc (mow goc 0x85eb.ca6b)
|
||||||
|
=. goc (mix goc (rsh 0 13 goc))
|
||||||
|
=. goc (mow goc 0xc2b2.ae35)
|
||||||
|
(mix goc (rsh 4 1 goc))
|
||||||
|
^= goc
|
||||||
|
=+ [inx=0 goc=syd]
|
||||||
|
|- ^- @
|
||||||
|
?: =(inx len) goc
|
||||||
|
=+ kop=(cut 5 [inx 1] key)
|
||||||
|
=. kop (mow kop 0xcc9e.2d51)
|
||||||
|
=. kop (row 15 kop)
|
||||||
|
=. goc (mix kop goc)
|
||||||
|
=. goc (row 13 goc)
|
||||||
|
=. goc (end 5 1 (add 0xe654.6b64 (mul 5 goc)))
|
||||||
|
$(inx +(inx))
|
||||||
|
::
|
||||||
++ mug :: 31bit nonzero FNV1a
|
++ mug :: 31bit nonzero FNV1a
|
||||||
~/ %mug
|
~/ %mug
|
||||||
|= a=*
|
|= a=*
|
||||||
|
@ -1046,7 +1046,7 @@
|
|||||||
^- ankz
|
^- ankz
|
||||||
^$(p ank)
|
^$(p ank)
|
||||||
::
|
::
|
||||||
++ ze !:
|
++ ze
|
||||||
|_ [lim=@da dome rang]
|
|_ [lim=@da dome rang]
|
||||||
++ zoal :: make yaki
|
++ zoal :: make yaki
|
||||||
|= [p=(list tako) q=(map path lobe) t=@da]
|
|= [p=(list tako) q=(map path lobe) t=@da]
|
||||||
@ -1356,7 +1356,7 @@
|
|||||||
$(gud (~(put in gud) tek), unk bun)
|
$(gud (~(put in gud) tek), unk bun)
|
||||||
$(unk bun)
|
$(unk bun)
|
||||||
::
|
::
|
||||||
++ zeas !: :: merge points fast
|
++ zeas :: merge points fast
|
||||||
|= [p=yaki q=yaki] :: (future zeal)
|
|= [p=yaki q=yaki] :: (future zeal)
|
||||||
^- (set yaki) :: zear still uses zule
|
^- (set yaki) :: zear still uses zule
|
||||||
%- zear :: this is test-only
|
%- zear :: this is test-only
|
||||||
@ -1374,7 +1374,7 @@
|
|||||||
(~(uni in u) (zeaz v))
|
(~(uni in u) (zeaz v))
|
||||||
$(u (~(uni in u) (zeaz v)), s (zeat s.qez), t (zeat t.qez))
|
$(u (~(uni in u) (zeaz v)), s (zeat s.qez), t (zeat t.qez))
|
||||||
::
|
::
|
||||||
++ zeaz !:
|
++ zeaz
|
||||||
|= qez=(set tako)
|
|= qez=(set tako)
|
||||||
^- (set yaki)
|
^- (set yaki)
|
||||||
%- sa %+ turn (~(tap in qez) ~)
|
%- sa %+ turn (~(tap in qez) ~)
|
||||||
|
Loading…
Reference in New Issue
Block a user