aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2013-07-03 18:05:36 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-03 19:07:45 -0400
commit351b2a1fe2d06f44b4c06d377744b2ac408b7407 (patch)
tree94566bc117b757bfab5c282d56c251121a7f33f9 /scripts/checkpatch.pl
parent7d0b6594e1055e3d4efcc28af11a8e42dd85ded4 (diff)
checkpatch: cache last camelcase hash as .checkpatch-camelcase.<commit>
Add a file to cache the CamelCase variables found by <commit> to reduce the time it takes to scan the include/ directory. Filename is '.checkpatch-camelcase.<commit>' and it is created only only if a .git directory exists. <commit> is determined by the last non-merge commit id in the include/ path. Reduces checkpatch run time by ~12 cpu seconds on my little netbook. 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>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl26
1 files changed, 26 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 0d94853079ec..6afcd1239ca5 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -399,7 +399,23 @@ sub seed_camelcase_includes {
399 return if ($camelcase_seeded); 399 return if ($camelcase_seeded);
400 400
401 my $files; 401 my $files;
402 my $camelcase_git_file = "";
403
402 if (-d ".git") { 404 if (-d ".git") {
405 my $git_last_include_commit = `git log --no-merges --pretty=format:"%h%n" -1 -- include`;
406 chomp $git_last_include_commit;
407 $camelcase_git_file = ".checkpatch-camelcase.$git_last_include_commit";
408 if (-f $camelcase_git_file) {
409 open(my $camelcase_file, '<', "$camelcase_git_file")
410 or warn "$P: Can't read '$camelcase_git_file' $!\n";
411 while (<$camelcase_file>) {
412 chomp;
413 $camelcase{$_} = 1;
414 }
415 close($camelcase_file);
416
417 return;
418 }
403 $files = `git ls-files include`; 419 $files = `git ls-files include`;
404 } else { 420 } else {
405 $files = `find $root/include -name "*.h"`; 421 $files = `find $root/include -name "*.h"`;
@@ -409,6 +425,16 @@ sub seed_camelcase_includes {
409 seed_camelcase_file($file); 425 seed_camelcase_file($file);
410 } 426 }
411 $camelcase_seeded = 1; 427 $camelcase_seeded = 1;
428
429 if ($camelcase_git_file ne "") {
430 unlink glob ".checkpatch-camelcase.*";
431 open(my $camelcase_file, '>', "$camelcase_git_file")
432 or warn "$P: Can't write '$camelcase_git_file' $!\n";
433 foreach (sort { lc($a) cmp lc($b) } keys(%camelcase)) {
434 print $camelcase_file ("$_\n");
435 }
436 close($camelcase_file);
437 }
412} 438}
413 439
414$chk_signoff = 0 if ($file); 440$chk_signoff = 0 if ($file);