- go :: BL.ByteString -> State Adler32checksum [Instruction]
- go fnew | fnew == BL.empty = return []
- | otherwise = do
- let (blk, blks) = BL.splitAt (fromIntegral blockSize) fnew
- adlerSum <- get
- let matches = M.lookup adlerSum f0AdlerTable >>
- M.lookup (blockSig blk) f0MD4Table
- case matches of
- Just idxs -> do
- modify (`adler32Update` blk)
- is <- go blks
- return $ RBlk (head idxs) : is
- Nothing -> do
- let c = BL.head blk
- modify (`adler32Update` BL.singleton c)
- is <- go (BL.tail (blk `mappend` blks))
- return $ RChar c : is
+ go :: Integer -> BL.ByteString -> State Adler32checksum [Instruction]
+ go startIdx fnew | fnew == BL.empty = return []
+ | otherwise = do
+ let (blk, blks) = BL.splitAt (fromIntegral blockSize) fnew
+ endIdx = startIdx + fromIntegral (BL.length blk) - 1
+ adlerSum <- get
+ let matches = M.lookup adlerSum f0AdlerTable >>
+ M.lookup (blockSig blk) f0MD4Table
+ case matches of
+ Just idxs -> do
+ modify (`adler32Update` blk)
+ is <- go (endIdx + 1) blks
+ return $ RBlk (head idxs) : is
+ Nothing -> do
+ let c = BL.head blk
+ modify (`adler32Update` BL.singleton c)
+ is <- go (startIdx + 1) (BL.tail (blk `mappend` blks))
+ return $ RChar c : is