ripgrep icon indicating copy to clipboard operation
ripgrep copied to clipboard

globset: add escaping mechanism

Open piegamesde opened this issue 2 years ago • 1 comments

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?

piegamesde avatar Nov 12 '21 17:11 piegamesde

@BurntSushi friendly ping

piegamesde avatar Dec 01 '21 12:12 piegamesde

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.

BurntSushi avatar Jul 08 '23 21:07 BurntSushi

And yeah, definitely no need to optimize a routine like this. Your signature and implementation are more than sufficient.

BurntSushi avatar Jul 08 '23 21:07 BurntSushi