[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH 2/2] findutils/grep.c: Short-circuit -v to bail out on first match
From: Ari Sundholm <ari () tuxera ! com>
Date: 2019-01-28 17:21:29
Message-ID: 322baa32-d5c9-c859-d16f-2aa5ddde1d45 () tuxera ! com
[Download RAW message or body]
On 1/28/19 6:11 PM, Walter Harms wrote:
> Betreff: Re: [PATCH 2/2] findutils/grep.c: Short-circuit -v to bail out on
> first match
> To: Ari Sundholm <ari@tuxera.com>
> Cc:
> Bcc:
> -=-=-=-=-=-=-=-=-=# Diese Zeile unbedingt stehen lassen - unterhalb beginnen Sie
> Ihren Mailtext #=-=-=-=-=-=-=-=-=-
>
>
> Am 28.01.2019 16:11, schrieb Ari Sundholm:
>> A small optimization. There is no need to try matching the current
>> input line against any further patterns if a match was already
>> found and -v is specified.
>>
>> Signed-off-by: Ari Sundholm <ari@tuxera.com>
>> Signed-off-by: Niko Vähäsarja <niko@tuxera.com>
>> ---
>> findutils/grep.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/findutils/grep.c b/findutils/grep.c
>> index 9d9da422c..6abefffdc 100644
>> --- a/findutils/grep.c
>> +++ b/findutils/grep.c
>> @@ -447,6 +447,9 @@ static int grep_file(FILE *file)
>> * at first match */
>> if (found && !invert_search)
>> goto do_found;
>> + else if (invert_search && found)
>> + break;
>> +
>> pattern_ptr = pattern_ptr->link;
>> } /* while (pattern_ptr) */
>>
>
> maybe
>
> if (found) {
> if (invert_search)
> break;
> else
> goto do_found;
> }
>
> is more easy to read ?
>
Indeed. I think the comment above the if should also be updated. I'll
submit a v2 soon.
Thank you,
Ari Sundholm
ari@tuxera.com
> just my 2 cents
>
> re,
> wh
>
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic