grep-regex: add fast path for -w/--word-regexp

Previously, ripgrep would always defer to the regex engine's capturing
matches in order to implement word matching. Namely, ripgrep would
determine the correct match offsets via a capturing group, since the
word regex is itself generated from the user supplied regex.

Unfortunately, the regex engine's capturing mode is still fairly slow,
so this commit adds a fast path to avoid capturing mode in the vast
majority of cases. See comments in the code for details.
This commit is contained in:
Andrew Gallant
2020-02-16 10:43:26 -05:00
parent 6a0e0147e0
commit cd8ec38a68
4 changed files with 101 additions and 4 deletions

1
Cargo.lock generated
View File

@@ -202,6 +202,7 @@ name = "grep-regex"
version = "0.1.5"
dependencies = [
"aho-corasick 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)",
"bstr 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"grep-matcher 0.1.3",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",