bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH v3] maint.mk: expand the prohibit_doubled_word regex


From: Ján Tomko
Subject: [PATCH v3] maint.mk: expand the prohibit_doubled_word regex
Date: Tue, 2 Aug 2016 15:41:13 +0200

This check has a static list of words that are checked for
repetitions. Expand it before running the perl script to
avoid using expensive captures. This decreases the cost
for libvirt from 1.66s to 0.66s.
* top/maint.mk (prohibit_doubled_word_expanded_): Define.
(sc_prohibit_doubled_word): Use it.
---
Rebased on top of the patch proposed by Jim Meyering for:
[PATCH 4/4] useless-if-before-free: skip non-matching lines early

v2: use make's 'join' and 'addprefix' instead of non-portable sed -r
v3: remove extra escaping of +

 ChangeLog    | 10 ++++++++++
 top/maint.mk |  7 ++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 8e8ba77..4a1f07a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2016-08-02  Ján Tomko  <address@hidden>
+
+       maint.mk: expand the prohibit_doubled_word regex
+       This check has a static list of words that are checked for
+       repetitions. Expand it before running the perl script to
+       avoid using expensive captures. This decreases the cost
+       for libvirt from 1.66s to 0.66s.
+       * top/maint.mk (prohibit_doubled_word_expanded_): Define.
+       (sc_prohibit_doubled_word): Use it.
+
 2016-07-26  Ján Tomko  <address@hidden>
 
        useless-if-before-free: skip non-matching lines early
diff --git a/top/maint.mk b/top/maint.mk
index 9ca2bd3..7dfc157 100644
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -962,8 +962,13 @@ perl_filename_lineno_text_ =                               
                \
     -e '    print "$$ARGV:$$n:$$v\n";'                                 \
     -e '  }'
 
+prohibit_doubled_words_ = \
+    the then in an on if is it but for or at and do to
+# expand the regex before running the check to avoid using expensive captures
+prohibit_doubled_word_expanded_ = \
+    $(join $(prohibit_doubled_words_),$(addprefix 
\s+,$(prohibit_doubled_words_)))
 prohibit_doubled_word_RE_ ?= \
-  /\b(then?|[iao]n|i[fst]|but|f?or|at|and|[dt]o)\s+\1\b/gims
+    /\b(?:$(subst $(space),|,$(prohibit_doubled_word_expanded_)))\b/gims
 prohibit_doubled_word_ =                                               \
     -e 'while ($(prohibit_doubled_word_RE_))'                          \
     $(perl_filename_lineno_text_)
-- 
2.7.3




reply via email to

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