Skip to content

Commit

Permalink
checkpatch: reduce is_maintained_obsolete lookup runtime
Browse files Browse the repository at this point in the history
The is_maintained_obsolete function can be called twice using the same
filename.  This function spawns a process using get_maintainer.pl.
Store the status of each filename when spawned and use the stored result
to eliminate the spawning of unnecessary duplicate child processes.

Example:

old:

  $ time ./scripts/checkpatch.pl hp100-Move-to-staging.patch > /dev/null

  real	0m1.767s
  user	0m1.634s
  sys	0m0.141s

new:

  $ time ./scripts/checkpatch.pl hp100-Move-to-staging.patch > /dev/null

  real	0m1.184s
  user	0m1.085s
  sys	0m0.103s

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Joe Perches <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
JoePerches authored and torvalds committed Dec 5, 2019
1 parent d439e6a commit cd28b11
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -874,14 +874,18 @@ sub seed_camelcase_file {
}
}

our %maintained_status = ();

sub is_maintained_obsolete {
my ($filename) = @_;

return 0 if (!$tree || !(-e "$root/scripts/get_maintainer.pl"));

my $status = `perl $root/scripts/get_maintainer.pl --status --nom --nol --nogit --nogit-fallback -f $filename 2>&1`;
if (!exists($maintained_status{$filename})) {
$maintained_status{$filename} = `perl $root/scripts/get_maintainer.pl --status --nom --nol --nogit --nogit-fallback -f $filename 2>&1`;
}

return $status =~ /obsolete/i;
return $maintained_status{$filename} =~ /obsolete/i;
}

sub is_SPDX_License_valid {
Expand Down

0 comments on commit cd28b11

Please sign in to comment.