]> Savannah Git Hosting - gnulib.git/commitdiff
useless-if-before-free: skip non-matching lines early
authorJán Tomko <jtomko@redhat.com>
Mon, 1 Aug 2016 17:54:47 +0000 (10:54 -0700)
committerJim Meyering <meyering@fb.com>
Tue, 2 Aug 2016 15:07:40 +0000 (08:07 -0700)
* build-aux/useless-if-before-free: First match each line with the
simple/quick /\bif\b/ and reject if there is no match. This often
saves the cost of the much more involved regular expression.
For libvirt, this decreases the cost from 1.44s to 1.02s.

ChangeLog
build-aux/useless-if-before-free

index 28327f2e19803d8d0f0bc173a5f2db7bb94384dd..8e8ba7771877bd5c7343187598e5c59a53a6fde5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2016-07-26  Ján Tomko  <jtomko@redhat.com>
+
+       useless-if-before-free: skip non-matching lines early
+       * build-aux/useless-if-before-free: First match each line with the
+       simple/quick /\bif\b/ and reject if there is no match. This often
+       saves the cost of the much more involved regular expression.
+       For libvirt, this decreases the cost from 1.44s to 1.02s.
+
 2016-07-26  Ján Tomko  <jtomko@redhat.com>
 
        maint.mk: speed up sc_po_check
index 1899b1ffd82f1c3a0ac7cadc87fac7a6523d6675..d7a8c0dc61bbc9d970e8cf31c1932d682b9e602f 100755 (executable)
@@ -4,7 +4,7 @@ eval '(exit $?0)' && eval 'exec perl -wST "$0" "$@"'
 # Detect instances of "if (p) free (p);".
 # Likewise "if (p != 0)", "if (0 != p)", or with NULL; and with braces.
 
-my $VERSION = '2016-01-12 23:13'; # UTC
+my $VERSION = '2016-08-01 17:47'; # UTC
 # The definition above must lie within the first 8 lines in order
 # for the Emacs time-stamp write hook (at end) to update it.
 # If you change this file with Emacs, please let the write hook
@@ -129,6 +129,9 @@ sub is_NULL ($)
           $err = EXIT_ERROR, next;
       while (defined (my $line = <FH>))
         {
+          # Skip non-matching lines early to save time
+          $line =~ /\bif\b/
+            or next;
           while ($line =~
               /\b(if\s*\(\s*([^)]+?)(?:\s*!=\s*([^)]+?))?\s*\)
               #  1          2                  3