]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/checksums/common/common.factor
factor: trim using lists
[factor.git] / basis / checksums / common / common.factor
index 104dadcf1d5258e16485d2c8a183792351e41d56..d313b238d70f8f3267ef096e5278b81d3bdafc15 100644 (file)
@@ -1,8 +1,7 @@
 ! Copyright (C) 2006, 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors byte-arrays byte-vectors checksums destructors
-grouping io io.backend io.binary io.encodings.binary io.files
-kernel make math sequences locals ;
+USING: accessors byte-arrays byte-vectors checksums endian
+grouping kernel make math sequences ;
 IN: checksums.common
 
 : calculate-pad-length ( length -- length' )
@@ -23,8 +22,6 @@ TUPLE: block-checksum-state < checksum-state
     { bytes-read integer }
     { block-size integer } ;
 
-M: block-checksum-state dispose drop ;
-
 GENERIC: checksum-block ( bytes checksum-state -- )
 
 ! Update the bytes-read before calculating checksum in case
@@ -48,11 +45,7 @@ M:: block-checksum-state add-checksum-bytes ( state data -- state )
     remain [ >byte-vector ] [ BV{ } clone ] if* >>bytes ;
 
 M: block-checksum checksum-bytes
-    initialize-checksum-state [
-        swap add-checksum-bytes get-checksum
-    ] with-disposal ;
+    [ swap add-checksum-bytes get-checksum ] with-checksum-state ;
 
 M: block-checksum checksum-stream
-    initialize-checksum-state [
-        swap add-checksum-stream get-checksum
-    ] with-disposal ;
+    [ swap add-checksum-stream get-checksum ] with-checksum-state ;