]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/checksums/wyhash/wyhash.factor
factor: trim using lists
[factor.git] / basis / checksums / wyhash / wyhash.factor
index cf999e513804c7cb299cede3f8186e3eb774782c..bff1f8a7a5dd9f8cd005c6be721a397f0d7edc16 100644 (file)
@@ -2,18 +2,17 @@
 ! See http://factorcode.org/license.txt for BSD license
 
 USING: accessors alien.c-types alien.data byte-arrays checksums
-grouping io.binary kernel literals math math.bitwise math.order
-sequences sequences.generalizations ;
-
+endian grouping kernel math math.bitwise
+sequences sequences.generalizations sequences.private ;
 IN: checksums.wyhash
 
 <PRIVATE
 
 :: wymum ( a b -- a' b' )
-    a -32 shift 32 bits >bignum :> Ha
-    b -32 shift 32 bits >bignum :> Hb
-    a 32 bits >bignum :> La
-    b 32 bits >bignum :> Lb
+    a -32 shift 32 bits :> Ha
+    b -32 shift 32 bits :> Hb
+    a 32 bits :> La
+    b 32 bits :> Lb
     Ha Hb W* :> RH
     Ha Lb W* :> RM0
     Hb La W* :> RM1
@@ -50,7 +49,7 @@ CONSTANT: P3 0x589965cc75374cc3
 
 :: native-mapper ( from to bytes c-type -- seq )
     from to bytes <slice>
-    bytes byte-array? little-endian? and
+    bytes byte-array? alien.data:little-endian? and
     [ c-type cast-array ]
     [ c-type heap-size <groups> [ le> ] map ] if ; inline
 
@@ -91,7 +90,7 @@ M:: wyhash checksum-bytes ( bytes checksum -- value )
             seed :> see1!
             seed :> see2!
             6 <groups> [
-                6 firstn :> ( n0 n1 n2 n3 n4 n5 )
+                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!
@@ -101,7 +100,7 @@ M:: wyhash checksum-bytes ( bytes checksum -- value )
 
         len/48 len/16 bytes uint64_t native-mapper [
             2 <groups> [
-                first2 :> ( n0 n1 )
+                first2-unsafe :> ( n0 n1 )
                 n0 P1 bitxor n1 seed bitxor wymix seed!
             ] each
         ] unless-empty