[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] maint: improve sc_long_lines syntax-check speed
From: |
Bernhard Voelker |
Subject: |
Re: [PATCH] maint: improve sc_long_lines syntax-check speed |
Date: |
Thu, 23 Oct 2014 15:21:45 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0 |
On 10/23/2014 12:33 PM, Pádraig Brady wrote:
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.
Good catch ...
diff --git a/cfg.mk b/cfg.mk
index d95bfac..4bc3792 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -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) } || :
... yet this would now probably let pass files with tabs like makefiles
(as the real counting acts on expanded output), wouldn't it?
Have a nice day,
Berny