bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 4/4] useless-if-before-free: skip non-matching lines early


From: Eric Blake
Subject: Re: [PATCH 4/4] useless-if-before-free: skip non-matching lines early
Date: Fri, 29 Jul 2016 15:46:43 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 07/26/2016 08:28 AM, Ján Tomko wrote:
> Check if there is any if keyword on the currently
> processed line by a simple regex before matching
> against the more expensive capturing regex.
> ---
>  ChangeLog                        | 8 ++++++++
>  build-aux/useless-if-before-free | 3 +++
>  2 files changed, 11 insertions(+)
> 

> +++ b/build-aux/useless-if-before-free
> @@ -129,6 +129,9 @@ sub is_NULL ($)
>            $err = EXIT_ERROR, next;
>        while (defined (my $line = <FH>))
>          {
> +          # Skip non-matching lines early to save time
> +          if (not $line =~ /\bif/) { next }

Do you want \bif\b, so as to avoid false positives on 'ifelse' or other
non-keywords with a common prefix?

> +
>            while ($line =~
>                /\b(if\s*\(\s*([^)]+?)(?:\s*!=\s*([^)]+?))?\s*\)
>                #  1          2                  3
> 

At any rate, this optimization makes total sense.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]