Skip to content

Commit

Permalink
fix nice limit testing
Browse files Browse the repository at this point in the history
current:
  Time (mean ± σ):      2.133 s ±  0.013 s    [User: 2.058 s, System: 0.067 s]
  Range (min … max):    2.121 s …  2.165 s    10 runs
  • Loading branch information
ianic committed Jan 20, 2024
1 parent 7e0b9f7 commit e526241
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/deflate.zig
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,13 @@ pub fn Deflate(comptime WriterType: type) type {
}
while (match_pos != Lookup.not_found and tries > 0) : (tries -= 1) {
const distance = pos - match_pos;
if (distance > consts.match.max_distance or
match_pos < self.win.offset) break;
if (distance > consts.match.max_distance or match_pos < self.win.offset)
break;

const match_length = self.win.match(match_pos, pos, length);
if (match_length > length) {
token = Token.initMatch(@intCast(distance), match_length);
if (length >= level.nice) {
if (match_length >= level.nice) {
// The match is good enough that we don't try to find a better one.
return token;
}
Expand Down

0 comments on commit e526241

Please sign in to comment.