ripgrep
ripgrep copied to clipboard
globset: add escaping mechanism
Closes #2060. The implementation is taken 1:1 from the glob crate. Function signatures may be subject to bike shedding.
I feel that there may be some optimization potential in the escape
method that doesn't allocate if there are no special characters to be escaped (probably by returning a Cow
), but I would have to benchmark it and creating globs is usually not on the critical path.
I've seen some Strategy
foo while skimming over the code. Will the crate automatically pick a Literal
strategy or do I need to do something to activate it?
@BurntSushi friendly ping
Thanks! I had to trim this PR down quite a bit as you added a bunch of stuff beyond pub fn escape(..) -> String
that I do not want.
And yes, Literal
should automatically be selected. And if it isn't, we should fix that. But nothing else should care about escaping.
And yeah, definitely no need to optimize a routine like this. Your signature and implementation are more than sufficient.