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
Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all
Unified · Split
| @@ -874,14 +874,18 @@ sub seed_camelcase_file { · 873 unmodified lines | |||
| 874 | } | 874 | } |
| 875 | } | 875 | } |
| 876 | 876 | ||
| 877 | our %maintained_status = (); | ||
| 878 | |||
| 877 | sub is_maintained_obsolete { | 879 | sub is_maintained_obsolete { |
| 878 | my ($filename) = @_; | 880 | my ($filename) = @_; |
| 879 | 881 | ||
| 880 | return 0 if (!$tree || !(-e "$root/scripts/get_maintainer.pl")); | 882 | return 0 if (!$tree || !(-e "$root/scripts/get_maintainer.pl")); |
| 881 | 883 | ||
| 882 | my $status = `perl $root/scripts/get_maintainer.pl --status --nom --nol --nogit --nogit-fallback -f $filename 2>&1`; | 884 | if (!exists($maintained_status{$filename})) { |
| 885 | $maintained_status{$filename} = `perl $root/scripts/get_maintainer.pl --status --nom --nol --nogit --nogit-fallback -f $filename 2>&1`; | ||
| 886 | } | ||
| 883 | 887 | ||
| 884 | return $status =~ /obsolete/i; | 888 | return $maintained_status{$filename} =~ /obsolete/i; |
| 885 | } | 889 | } |
| 886 | 890 | ||
| 887 | sub is_SPDX_License_valid { | 891 | sub is_SPDX_License_valid { |