]> gitweb.factorcode.org Git - factor.git/commitdiff
checksums.crc16: use literals to build the table
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 10 Jan 2022 20:34:46 +0000 (12:34 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 10 Jan 2022 20:34:46 +0000 (12:34 -0800)
basis/checksums/crc16/crc16.factor

index 0097b07c940bb4a58697ec0cb83574597be5de75..1bb2a37422c48b431c8d0a4a3d77f4a21f34141b 100644 (file)
@@ -1,17 +1,17 @@
 ! Copyright (C) 2016 Alexander Ilin.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: checksums endian kernel math sequences sequences.private ;
+USING: checksums endian kernel literals math sequences sequences.private ;
 IN: checksums.crc16
 
 CONSTANT: crc16-polynomial 0xa001
 
-CONSTANT: crc16-table V{ }
-
-256 <iota> [
-    8 [
-        [ 2/ ] [ even? ] bi [ crc16-polynomial bitxor ] unless
-    ] times
-] map 0 crc16-table copy
+CONSTANT: crc16-table $[
+    256 <iota> [
+        8 [
+            [ 2/ ] [ even? ] bi [ crc16-polynomial bitxor ] unless
+        ] times
+    ] map
+]
 
 : (crc16) ( crc ch -- crc )
     dupd bitxor