The comment indicates len-(STD_MIN_MATCH-1), note the -1, while the actual code uses +1:
|
/* Try hash head at len-(STD_MIN_MATCH-1) position to see if we could get |
|
* a better cur_match at the end of string. Using (STD_MIN_MATCH-1) lets |
|
* us include one more byte into hash - the byte which will be checked |
|
* in main loop now, and which allows to grow match by 1. |
|
*/ |
|
let [scan0, scan1, scan2, ..] = scan[len - (STD_MIN_MATCH + 1)..] else { |
|
panic!("index out of bounds"); |
|
}; |
Changing the code to -1 to match by the comment doesn't break any tests. So this codepath might be untested?
FWIW upstream zlib-ng also has this mismatch:
https://github.com/zlib-ng/zlib-ng/blob/c2712b8a345191f6ed79558c089777df94590087/match_tpl.h#L204-L209
The comment indicates
len-(STD_MIN_MATCH-1), note the-1, while the actual code uses+1:zlib-rs/zlib-rs/src/deflate/longest_match.rs
Lines 302 to 309 in 0c161ed
Changing the code to -1 to match by the comment doesn't break any tests. So this codepath might be untested?
FWIW upstream zlib-ng also has this mismatch:
https://github.com/zlib-ng/zlib-ng/blob/c2712b8a345191f6ed79558c089777df94590087/match_tpl.h#L204-L209