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

@@ -12,6 +12,8 @@ Performance improvements:
of ` `.
* PERF:
Improve literal detection when the `-w/--word-regexp` flag is used.
* PERF:
Improve overall performance of the `-w/--word-regexp` flag.
Feature enhancements: