]> Savannah Git Hosting - gnulib.git/commitdiff
maint.mk: expand the prohibit_doubled_word regex
authorJán Tomko <jtomko@redhat.com>
Tue, 2 Aug 2016 13:41:13 +0000 (15:41 +0200)
committerJim Meyering <meyering@fb.com>
Tue, 2 Aug 2016 15:31:43 +0000 (08:31 -0700)
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.

ChangeLog
top/maint.mk

index 8e8ba7771877bd5c7343187598e5c59a53a6fde5..7cfc6f73c9d47cc37c40481539cff3b01f4ba102 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2016-08-02  Ján Tomko  <jtomko@redhat.com>
+
+       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  <jtomko@redhat.com>
 
        useless-if-before-free: skip non-matching lines early
index 9ca2bd3b32544a040e89e291834bd4a440fe825d..868e10f004f8770edf2e8d2a6f9e84f18f431e68 100644 (file)
@@ -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 $(_sp),|,$(prohibit_doubled_word_expanded_)))\b/gims
 prohibit_doubled_word_ =                                               \
     -e 'while ($(prohibit_doubled_word_RE_))'                          \
     $(perl_filename_lineno_text_)