]> gitweb.factorcode.org Git - factor.git/commitdiff
checksums: add specialized-arrays.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 17 Mar 2021 04:14:05 +0000 (21:14 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 17 Mar 2021 04:17:00 +0000 (21:17 -0700)
basis/checksums/wyhash/wyhash.factor
basis/checksums/xxhash/xxhash.factor

index cf999e513804c7cb299cede3f8186e3eb774782c..00492f98ecf7a1cf9532bd46b0d60b1d819afe94 100644 (file)
@@ -3,17 +3,18 @@
 
 USING: accessors alien.c-types alien.data byte-arrays checksums
 grouping io.binary kernel literals math math.bitwise math.order
-sequences sequences.generalizations ;
-
+sequences sequences.generalizations sequences.private
+specialized-arrays ;
+SPECIALIZED-ARRAY: uint64_t
 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
@@ -91,7 +92,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 +102,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
index ea6869e4821c1c1c79bfb940b36e1825a5231ba1..1437eb81d94c2eb536e22bb9e3ee7c9c844cb14f 100644 (file)
@@ -3,7 +3,9 @@
 
 USING: accessors alien alien.c-types alien.data byte-arrays
 checksums combinators generalizations grouping io.binary kernel
-locals math math.bitwise math.ranges sequences ;
+locals math math.bitwise math.ranges sequences
+specialized-arrays ;
+SPECIALIZED-ARRAY: uint64_t
 
 IN: checksums.xxhash