coreutils
[Top][All Lists]
Advanced

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

[PATCH] maint: improve sc_long_lines syntax-check speed


From: Pádraig Brady
Subject: [PATCH] maint: improve sc_long_lines syntax-check speed
Date: Thu, 23 Oct 2014 11:33:09 +0100

sc_long_lines was the slowest syntax check

before$ time make sc_long_lines
        long_lines
        real    0m2.740s

after $ time make sc_long_lines
        long_lines
        real    0m0.677s

* src/cfg.mk (sc_dd_max_sym_length): s/--max-line-length/-L/
for compat with BSDs.
(sc_long_lines): Prefilter with wc -L to only identify lines
in files that have lines longer than 80 characters.
---
 cfg.mk |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/cfg.mk b/cfg.mk
index d95bfac..4bc3792 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -74,10 +74,9 @@ sc_dd_max_sym_length:
 ifneq ($(wildcard $(dd_c)),)
        @len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\
                 sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) )      \
-               |sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p'         \
-             | wc --max-line-length);                          \
+               |sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p'| wc -L);\
        max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
-             |tr -d '"' | wc --max-line-length);               \
+             |tr -d '"' | wc -L);              \
        if test "$$len" = "$$max"; then :; else                 \
          echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2;      \
          exit 1;                                               \
@@ -239,17 +238,17 @@ sc_prohibit-gl-attributes:
 # - the help2man script copied from upstream,
 # - tests involving long checksum lines, and
 # - the 'pr' test cases.
-LINE_LEN_MAX = 80
 FILTER_LONG_LINES =                                            \
   /^[^:]*\.diff:[^:]*:@@ / d;                                  \
   \|^[^:]*man/help2man:| d;                    \
   \|^[^:]*tests/misc/sha[0-9]*sum.*\.pl[-:]| d;                        \
   \|^[^:]*tests/pr/|{ \|^[^:]*tests/pr/pr-tests:| !d; };
 sc_long_lines:
-       @files=$$($(VC_LIST_EXCEPT))                                    \
-       halt='line(s) with more than $(LINE_LEN_MAX) characters; reindent'; \
+       @files=$$($(VC_LIST_EXCEPT) | xargs wc -L | sed -rn '/ total$$/d;\
+                 s/^ *(8[1-9]|9[0-9]|[0-9]\{3,\}) //p');               \
+       halt='line(s) with more than 80 characters; reindent';          \
        for file in $$files; do                                         \
-         expand $$file | grep -nE '^.{$(LINE_LEN_MAX)}.' |             \
+         expand $$file | grep -nE '^.{80}.' |                          \
          sed -e "s|^|$$file:|" -e '$(FILTER_LONG_LINES)';              \
        done | grep . && { msg="$$halt" $(_sc_say_and_exit) } || :
 
-- 
1.7.7.6




reply via email to

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