diff options
Diffstat (limited to 'c/enc/hash_longest_match_inc.h')
-rw-r--r-- | c/enc/hash_longest_match_inc.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/c/enc/hash_longest_match_inc.h b/c/enc/hash_longest_match_inc.h index b744f4d..58e88b3 100644 --- a/c/enc/hash_longest_match_inc.h +++ b/c/enc/hash_longest_match_inc.h @@ -192,8 +192,10 @@ static BROTLI_INLINE void FN(FindLongestMatch)( } prev_ix &= ring_buffer_mask; - if (cur_ix_masked + best_len > ring_buffer_mask || - prev_ix + best_len > ring_buffer_mask || + if (cur_ix_masked + best_len > ring_buffer_mask) { + break; + } + if (prev_ix + best_len > ring_buffer_mask || data[cur_ix_masked + best_len] != data[prev_ix + best_len]) { continue; } @@ -234,8 +236,10 @@ static BROTLI_INLINE void FN(FindLongestMatch)( break; } prev_ix &= ring_buffer_mask; - if (cur_ix_masked + best_len > ring_buffer_mask || - prev_ix + best_len > ring_buffer_mask || + if (cur_ix_masked + best_len > ring_buffer_mask) { + break; + } + if (prev_ix + best_len > ring_buffer_mask || /* compare 4 bytes ending at best_len + 1 */ BrotliUnalignedRead32(&data[cur_ix_masked + best_len - 3]) != BrotliUnalignedRead32(&data[prev_ix + best_len - 3])) { |