add support for -F/--fixed-strings

Bug #539263 reported by Parth Malwankar
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bzr-grep
Fix Released
Wishlist
Unassigned

Bug Description

bzr-grep should have support for -F/--fixed-strings. This will allow searches to be faster when user isn't interested in pattern matching.

Parth Malwankar (parthm)
Changed in bzr-grep:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Martin Pool (mbp) wrote : Re: [Bug 539263] [NEW] add support for -F/--fixed-strings

You could perhaps turn this on automatically if the pattern is
detected to not contain any metacharacters, which is probably pretty
common.

--
Martin <http://launchpad.net/~mbp/>

Revision history for this message
Parth Malwankar (parthm) wrote :

On Wed, Mar 17, 2010 at 5:45 AM, Martin Pool <email address hidden> wrote:
> You could perhaps turn this on automatically if the pattern is
> detected to not contain any metacharacters, which is probably pretty
> common.
>

Sounds like a good idea.

Another option could be that, rather than doing magic, we could
make this the default and have a -e flag for taking this as pattern.

As per the grep manual, -F will:

Interpret PATTERN as a list of fixed strings, separated by
newlines, any of which is to be matched. (-F is specified by
POSIX.)

I am wonder how important the "list" part of "list of fixed strings"
is. I think supporting just one string would be very fast and cover
most cases.

What do you think?

Revision history for this message
Martin Pool (mbp) wrote :

On 17 March 2010 13:01, Parth Malwankar <email address hidden> wrote:
> On Wed, Mar 17, 2010 at 5:45 AM, Martin Pool <email address hidden> wrote:
>> You could perhaps turn this on automatically if the pattern is
>> detected to not contain any metacharacters, which is probably pretty
>> common.
>>
>
> Sounds like a good idea.
>
> Another option could be that, rather than doing magic, we could
> make this the default and have a -e flag for taking this as pattern.

I think people would be confused if they give a regexp and it's not
matched as such.

>
> As per the grep manual, -F will:
>
> Interpret  PATTERN  as a list of fixed strings, separated by
> newlines, any of which is to be matched.  (-F is specified by
> POSIX.)
>
> I am wonder how important the "list" part of "list of fixed strings"
> is. I think supporting just one string would be very fast and cover
> most cases.

I think so too. I've never used that grep feature.

--
Martin <http://launchpad.net/~mbp/>

Revision history for this message
Parth Malwankar (parthm) wrote :

On Wed, Mar 17, 2010 at 7:46 AM, Martin Pool <email address hidden> wrote:
> On 17 March 2010 13:01, Parth Malwankar <email address hidden> wrote:
>> On Wed, Mar 17, 2010 at 5:45 AM, Martin Pool <email address hidden> wrote:
>>> You could perhaps turn this on automatically if the pattern is
>>> detected to not contain any metacharacters, which is probably pretty
>>> common.
>>>
>>
>> Sounds like a good idea.
>>
>> Another option could be that, rather than doing magic, we could
>> make this the default and have a -e flag for taking this as pattern.
>
> I think people would be confused if they give a regexp and it's not
> matched as such.
>

Sounds reasonable, so if the pattern isalnum() == True, I will go
with -F (apart from the explicit -F). That should be a safe enough
whitelist.

Revision history for this message
Parth Malwankar (parthm) wrote :

Added -F/--fixed-string support. This is different from --fixed-strings in that the PATTERN is assumed to be a single string (and not newline delimited strings). As an optimization, simple aphanumeric PATTERN implicitly set -F.

For a large tree like emacs, working copy search time has gone from ~4.5s to ~2.4s on my system.

Changed in bzr-grep:
status: Confirmed → Fix Committed
Parth Malwankar (parthm)
Changed in bzr-grep:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.