unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/3] learn: reduce parameter passing
Date: Fri, 25 Oct 2024 03:19:56 +0000	[thread overview]
Message-ID: <20241025031957.1305385-3-e@80x24.org> (raw)
In-Reply-To: <20241025031957.1305385-1-e@80x24.org>

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 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/script/public-inbox-learn b/script/public-inbox-learn
index dae4400f..12a82de9 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});
 	}
 }
 

  parent reply	other threads:[~2024-10-25  3:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-25  3:19 [PATCH 0/3] learn: support --keep-going + cleanups Eric Wong
2024-10-25  3:19 ` [PATCH 1/3] learn: support --keep-going/-k switch Eric Wong
2024-10-25  3:19 ` Eric Wong [this message]
2024-10-25  3:19 ` [PATCH 3/3] learn: use Perl 5.12 Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241025031957.1305385-3-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).