]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
learn: reduce parameter passing
authorEric Wong <e@80x24.org>
Fri, 25 Oct 2024 03:19:56 +0000 (03:19 +0000)
committerEric Wong <e@80x24.org>
Mon, 28 Oct 2024 22:55:31 +0000 (22:55 +0000)
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.

script/public-inbox-learn

index dae4400fa7926a88daf3716d7d520d3e0fa4d1eb..12a82de99e7de415404ffa326ac6188fe393d6ad 100755 (executable)
@@ -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});
        }
 }