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

View File

@@ -14,6 +14,7 @@ license = "Unlicense/MIT"
[dependencies]
aho-corasick = "0.7.3"
bstr = "0.2.10"
grep-matcher = { version = "0.1.2", path = "../grep-matcher" }
log = "0.4.5"
regex = "1.1"