Mercurial > gnulib
changeset 18356:7feee6d944f8
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.
author | Ján Tomko <jtomko@redhat.com> |
---|---|
date | Mon, 01 Aug 2016 10:54:47 -0700 |
parents | 5f691c615e16 |
children | 454e054b95a9 |
files | ChangeLog build-aux/useless-if-before-free |
diffstat | 2 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Aug 02 06:00:57 2016 -0700 +++ b/ChangeLog Mon Aug 01 10:54:47 2016 -0700 @@ -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
--- a/build-aux/useless-if-before-free Tue Aug 02 06:00:57 2016 -0700 +++ b/build-aux/useless-if-before-free Mon Aug 01 10:54:47 2016 -0700 @@ -4,7 +4,7 @@ # 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 @@ $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