Handbook
Glossary
block-checksum-state
Vocabulary
checksums
.
common
Definition
USING:
checksums
math
;
IN:
checksums.common
TUPLE:
block-checksum-state
<
checksum-state
{
bytes-read
integer
initial:
0
}
{
block-size
integer
initial:
0
}
;
Methods
USING:
accessors
byte-vectors
checksums
checksums.common
grouping
kernel
math
sequences
;
M::
block-checksum-state
add-checksum-bytes
( state data -- checksum-state )
state
block-size>>
:>
block-size state
bytes>>
length
:>
initial-len initial-len data
length
+
block-size
/mod
:>
( n extra ) data state
bytes>>
[
push-all
]
keep
:>
all-bytes all-bytes block-size
<groups>
extra
zero?
[
f
]
[
unclip-last-slice
]
if
:>
( blocks remain ) state
[
initial-len
-
]
change-bytes-read
drop
blocks
[
state
[
block-size
+
]
change-bytes-read
checksum-block
]
each
state
[
extra
+
]
change-bytes-read
remain
[
>byte-vector
]
[
BV{
}
clone
]
if*
>>bytes
;