diff --git a/pkg/rollsum/rollsum.go b/pkg/rollsum/rollsum.go index 4a66d7055..ca1eee681 100644 --- a/pkg/rollsum/rollsum.go +++ b/pkg/rollsum/rollsum.go @@ -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()