[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/4] useless-if-before-free: skip non-matching lines early
From: |
Ján Tomko |
Subject: |
[PATCH 4/4] useless-if-before-free: skip non-matching lines early |
Date: |
Tue, 26 Jul 2016 16:28:17 +0200 |
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(+)
diff --git a/ChangeLog b/ChangeLog
index 64e2026..5aebb2f 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
+
+ Check if there is any if keyword on the currently
+ processed line by a simple regex before matching
+ against the more expensive capturing regex.
+
+2016-07-26 Ján Tomko <address@hidden>
+
maint.mk: speed up require_config_h_first
Instead of spawning three processes per file, rewrite the check
diff --git a/build-aux/useless-if-before-free b/build-aux/useless-if-before-free
index 1899b1f..185ccfc 100755
--- a/build-aux/useless-if-before-free
+++ 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 }
+
while ($line =~
/\b(if\s*\(\s*([^)]+?)(?:\s*!=\s*([^)]+?))?\s*\)
# 1 2 3
--
2.7.3