This commit is contained in:
Ryan Oldenburg 2020-11-06 16:42:32 -06:00
parent e16f9f29e3
commit adc901f9d6
1 changed files with 6 additions and 9 deletions

View File

@ -57,26 +57,23 @@ proc lz77Encode2(src: seq[uint8]): seq[uint16] =
inc pos inc pos
continue continue
windowPos = pos and (windowSize - 1)
updateHash(src[pos + minMatchLen - 1]) updateHash(src[pos + minMatchLen - 1])
updateChain() updateChain()
windowPos = pos and (windowSize - 1)
var var
hashPos = chain[pos] hashPos = chain[pos]
stop = min(src.len, pos + maxMatchLen) stop = min(src.len, pos + maxMatchLen)
chainLen, longestMatchOffset, longestMatchLen: int chainLen, prevOffset, longestMatchOffset, longestMatchLen: int
while true: while true:
if chainLen >= maxChainLen: if chainLen >= maxChainLen:
break break
inc chainLen inc chainLen
let offset = pos - hashPos
# let offset = pos - hashPos if offset == 0:
# if offset == 0: break
# break
var matchLen: int var matchLen: int
for i in 0 ..< stop - pos: for i in 0 ..< stop - pos: