aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2013-09-11 17:24:03 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-11 18:58:48 -0400
commit1b5539b1ffbdcf7113eebea7f37141d4468d9070 (patch)
tree3c58c77b71cf7da626d966e018856b1e64932890
parentb34c648bb33ca143b98851fd7fe7250f1875c463 (diff)
checkpatch: reduce runtime/cpu time used
There are some cases where checkpatch can take a long time to complete. Reduce the likelihood of this long run-time by adding a new test for lines with and without comments and eliminating checks on lines with only comments. This reduces the number of "ctx_statement_block" calls, and also the number of tests of $stat, which is now undefined for these blank lines. One test in particular, the "check for switch/default statements without a break", could take an extremely long time to parse as it tries to skip interleaving comments within the ctx_statement_block/$stat and that could be done multiple times unnecessarily. A small test case taken from cfg80211.h before this patch would take 1000's of seconds to run, now it's just a couple seconds. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rwxr-xr-xscripts/checkpatch.pl4
1 files changed, 3 insertions, 1 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e53df2b086b2..55277a8e1527 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1678,6 +1678,8 @@ sub process {
1678 $linenr = 0; 1678 $linenr = 0;
1679 foreach my $line (@lines) { 1679 foreach my $line (@lines) {
1680 $linenr++; 1680 $linenr++;
1681 my $sline = $line; #copy of $line
1682 $sline =~ s/$;/ /g; #with comments as spaces
1681 1683
1682 my $rawline = $rawlines[$linenr - 1]; 1684 my $rawline = $rawlines[$linenr - 1];
1683 1685
@@ -2194,7 +2196,7 @@ sub process {
2194 $realline_next); 2196 $realline_next);
2195#print "LINE<$line>\n"; 2197#print "LINE<$line>\n";
2196 if ($linenr >= $suppress_statement && 2198 if ($linenr >= $suppress_statement &&
2197 $realcnt && $line =~ /.\s*\S/) { 2199 $realcnt && $sline =~ /.\s*\S/) {
2198 ($stat, $cond, $line_nr_next, $remain_next, $off_next) = 2200 ($stat, $cond, $line_nr_next, $remain_next, $off_next) =
2199 ctx_statement_block($linenr, $realcnt, 0); 2201 ctx_statement_block($linenr, $realcnt, 0);
2200 $stat =~ s/\n./\n /g; 2202 $stat =~ s/\n./\n /g;