From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 6CDD11F4C4 for ; Fri, 25 Oct 2024 03:19:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1729826398; bh=cRPItHwJR/sUkyPnYrWCgB8DbqayP/fs5u8/vQjDxQU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=5LAQEy8FAwS7xSi6NxecgP3B2JnxBBsELIpPpuBATlm6ONftO7urcIsN/py5aQS0y mJyzfTR90nnry/A8XCSYjgO2SqDfJkMZEiivXToQUkK9Qpu39efaHM/uok+fNpquKy 9VPfYxXFdV6Y3vaczVtVOwPZC9st4eA7a+bCgtQ8= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/3] learn: reduce parameter passing Date: Fri, 25 Oct 2024 03:19:56 +0000 Message-ID: <20241025031957.1305385-3-e@80x24.org> In-Reply-To: <20241025031957.1305385-1-e@80x24.org> References: <20241025031957.1305385-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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}); } }