From: Eric Wong Date: Fri, 25 Oct 2024 03:19:56 +0000 (+0000) Subject: learn: reduce parameter passing X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=554ff4d9c6c4bd62b8178c5dd3ca1dbf1c520ed3;p=thirdparty%2Fpublic-inbox.git learn: reduce parameter passing Since $remove_or_add is now a locally-scoped anonymous sub, it can access `global' variables under TestCommon::key2sub and avoid shadowing the names of global variables. --- diff --git a/script/public-inbox-learn b/script/public-inbox-learn index dae4400fa..12a82de99 100755 --- a/script/public-inbox-learn +++ b/script/public-inbox-learn @@ -69,7 +69,7 @@ my $ibx_fail = sub { }; my $remove_or_add = sub { - my ($ibx, $train, $mime, $addr) = @_; + my ($ibx, $addr) = @_; eval { # We do not touch GIT_COMMITTER_* env here so we can track # who trained the message. @@ -130,12 +130,12 @@ if ($train eq 'spam' || ($train eq 'rm' && $opt{all})) { while (my ($addr, $ibx) = each %dests) { next unless ref($ibx); # $ibx may be 0 next if $seen{0 + $ibx}++; - $remove_or_add->($ibx, $train, $mime, $addr); + $remove_or_add->($ibx, $addr); } my $dests = PublicInbox::MDA->inboxes_for_list_id($pi_cfg, $mime); for my $ibx (@$dests) { next if $seen{0 + $ibx}++; - $remove_or_add->($ibx, $train, $mime, $ibx->{-primary_address}); + $remove_or_add->($ibx, $ibx->{-primary_address}); } }