mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-06-25 14:22:54 +02:00
regex: special case literal extraction
In a prior commit, we fixed a performance problem with the -w flag by doing a little extra work to extract literals. It turns out that using literals in this case when the -w flag is NOT used results in a performance regression. The reasoning is that we end up using a "fast" regex as a prefilter when the regex engine itself uses its own equivalent prefilter, so ripgrep ends up redoing a fair amount of work. Instead, we only do this extra work when we know the -w flag is enabled.
This commit is contained in:
@ -141,6 +141,9 @@ impl LiteralSets {
|
|||||||
// (Not in theory---it could be better. But the current
|
// (Not in theory---it could be better. But the current
|
||||||
// implementation isn't good enough.) ... So we make up for it
|
// implementation isn't good enough.) ... So we make up for it
|
||||||
// here.
|
// here.
|
||||||
|
if !word {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
let p_min_len = self.prefixes.min_len();
|
let p_min_len = self.prefixes.min_len();
|
||||||
let s_min_len = self.suffixes.min_len();
|
let s_min_len = self.suffixes.min_len();
|
||||||
let lits = match (p_min_len, s_min_len) {
|
let lits = match (p_min_len, s_min_len) {
|
||||||
|
Reference in New Issue
Block a user