mirror of https://github.com/perkeep/perkeep.git
rollsum: add OnSplitWithBits
Change-Id: I6646695fdffbe8df697c54dab9a0601a0bf59459
This commit is contained in:
parent
70afe9597a
commit
fbc3af2673
|
@ -53,10 +53,19 @@ func (rs *RollSum) Roll(ch byte) {
|
|||
rs.wofs = (rs.wofs + 1) % windowSize
|
||||
}
|
||||
|
||||
// OnSplit returns whether at least 13 consecutive trailing bits of
|
||||
// the current checksum are set the same way.
|
||||
func (rs *RollSum) OnSplit() bool {
|
||||
return (rs.s2 & (blobSize - 1)) == ((^0) & (blobSize - 1))
|
||||
}
|
||||
|
||||
// OnSplit returns whether at least n consecutive trailing bits
|
||||
// of the current checksum are set the same way.
|
||||
func (rs *RollSum) OnSplitWithBits(n uint32) bool {
|
||||
mask := (uint32(1) << n) - 1
|
||||
return rs.s2 & mask == (^uint32(0)) & mask
|
||||
}
|
||||
|
||||
func (rs *RollSum) Bits() int {
|
||||
bits := blobBits
|
||||
rsum := rs.Digest()
|
||||
|
|
Loading…
Reference in New Issue