Skip to content

Commit

Permalink
Move scan_start check, based on Cloudflare commit
Browse files Browse the repository at this point in the history
5f1bd2b72e5966aa8a4f942e6e8050a050161cf9
  • Loading branch information
Dead2 committed Oct 22, 2019
1 parent 4c59062 commit cdbc900
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions match_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@ static inline unsigned longest_match(deflate_state *const s, IPos cur_match) {
int cont = 1;
do {
match = window + cur_match;
if (likely(memcmp(match+best_len-1, &scan_end, sizeof(scan_end)) != 0)) {
if (likely(memcmp(match+best_len-1, &scan_end, sizeof(scan_end)) != 0
|| memcmp(match, &scan_start, sizeof(scan_start)) != 0)) {
if ((cur_match = prev[cur_match & wmask]) > limit
&& --chain_length != 0) {
continue;
Expand All @@ -446,9 +447,6 @@ static inline unsigned longest_match(deflate_state *const s, IPos cur_match) {
if (!cont)
break;

if (memcmp(match, &scan_start, sizeof(scan_start)) != 0)
continue;

/* It is not necessary to compare scan[2] and match[2] since they are
* always equal when the other bytes match, given that the hash keys
* are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
Expand Down

0 comments on commit cdbc900

Please sign in to comment.