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: Ján Tomko
Subject: Re: [PATCH 4/4] useless-if-before-free: skip non-matching lines early
Date: Tue, 2 Aug 2016 13:01:29 +0200
User-agent: Mutt/1.5.24 (2015-08-30)

On Mon, Aug 01, 2016 at 10:56:15AM -0700, Jim Meyering wrote:
On Mon, Aug 1, 2016 at 5:11 AM, Ján Tomko <address@hidden> wrote:
1.44s to 1.02s

Thanks. Mentioned that in the commit log.
Here is the proposed patch:

From 3238fa6a54927c1af81dbd2c512f5e6ead8dcfc2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <address@hidden>
Date: Mon, 1 Aug 2016 10:54:47 -0700
Subject: [PATCH] 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.
---
ChangeLog                        | 8 ++++++++
build-aux/useless-if-before-free | 5 ++++-
2 files changed, 12 insertions(+), 1 deletion(-)


Looks good to me,

diff --git a/ChangeLog b/ChangeLog
index 28327f2..8e8ba77 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2016-07-26  Ján Tomko  <address@hidden>

+       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  <address@hidden>
+
        maint.mk: speed up sc_po_check
        sc_po_check would skip files based on their names, or on the
        existence of files with derived names. Rewrite it to use perl

however this context hunk is from commit
5fb8cef6494aca3108e9d8644395b948720e77ba
   maint.mk: speed up sc_po_check
which contains nothing else but the ChangeLog entry duplicated from:
04fd8821111d3af23e8485f0f78b60f42babda1d
   maint.mk: speed up sc_po_check

Jan

diff --git a/build-aux/useless-if-before-free b/build-aux/useless-if-before-free
index 1899b1f..d7a8c0d 100755
--- a/build-aux/useless-if-before-free
+++ b/build-aux/useless-if-before-free
@@ -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
--
2.8.0-rc2


Attachment: signature.asc
Description: Digital signature


reply via email to

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