Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
literal: fix reverse suffix optimization
This commit fixes a bug where the reverse suffix literal optimization wasn't quite right. It was too eagerly skipping past parts of the input without verifying that there was no match. We fix this by being a bit more careful with what we're searching by keeping track of the starting position of the last literal matched. Subsequent literal searches then start immediately after the last one. This is necessary in particular when the suffix literal can have overlapping matches. e.g., searching `000` in `0000` can match at either positions 0 or 1, but searching `abc` in `abcd` can only match as position 0. This was initially reported as a bug against ripgrep: BurntSushi/ripgrep#1203
- Loading branch information