prtwash.pl: use a hash map to test files against the keeplist

This commit is contained in:
John McQuah 2023-08-07 08:46:44 -04:00
parent c04e9cf3e8
commit 9ca23cc68d
1 changed files with 3 additions and 4 deletions

View File

@ -180,17 +180,16 @@ sub do_wash {
print "WARN: no Pkgfile found in $port. Skipping.\n";
return;
} else {
my @keepers = keeplist($port); my $iswanted;
my @keepers = keeplist($port);
my $allbuilds = pop(@keepers);
my $currbuild = pop(@keepers);
my %iswanted = map { $_ => 1 } @keepers;
opendir (DIR,$port) or return;
print "=====> washing $port\n" unless $options{quiet} == 1;
foreach my $f (sort(readdir(DIR))) {
next if ($f eq '.' or $f eq '..');
$f =~ s/\+/\\\+/g; # plus sign in filenames interferes with regex search
$iswanted = ( grep (/$f/, @keepers ) >= 1 );
if ($iswanted or ($options{pkgtoo}==0)*($f =~ /$currbuild/)
if ($iswanted{$f} or ($options{pkgtoo}==0)*($f =~ /$currbuild/)
or ($options{oldver}==0)*($f =~ /$allbuilds/)*($f !~ /$currbuild/)) {
print "... keeping file $port/$f.\n" unless $options{quiet} == 1;
} else {