Skip to content

Commit

Permalink
small
Browse files Browse the repository at this point in the history
  • Loading branch information
guzba committed Nov 14, 2020
1 parent 626865b commit 4ccf8f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Each file is compressed 1000 times.
**https://github.com/guzba/zippy** results:
File | Time | Size Reduction
--- | --- | ---:
alice29.txt | 3.8033s | 63.32%
alice29.txt | 3.7915s | 63.32%
urls.10K | 19.4417s | 67.49%
rfctest3.gold | 0.7493s | 70.73%
randtest3.gold | 0.1258s | 0%
Expand Down
14 changes: 6 additions & 8 deletions src/zippy/common.nim
Original file line number Diff line number Diff line change
Expand Up @@ -228,19 +228,17 @@ func findMatchLength*(src: seq[uint8], s1, s2, limit: int): int {.inline.} =
s2 = s2
while s2 <= limit - 8:
let x = read64(src, s2) xor read64(src, s1 + result)
if x == 0:
inc(s2, 8)
inc(result, 8)
else:
if x != 0:
let matchingBits = countTrailingZeroBits(x)
inc(result, matchingBits shr 3)
return
inc(s2, 8)
inc(result, 8)
while s2 < limit:
if src[s2] == src[s1 + result]:
inc s2
inc result
else:
if src[s2] != src[s1 + result]:
return
inc s2
inc result

func adler32*(data: seq[uint8]): uint32 =
## See https://github.com/madler/zlib/blob/master/adler32.c
Expand Down

0 comments on commit 4ccf8f0

Please sign in to comment.