Skip to content

Suspicious mismatch between comments and code #499

Description

@Shnatsel

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions