From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/4] learn: fix redundant ham import on dual matches
Date: Sat, 11 Nov 2023 09:04:56 +0000 [thread overview]
Message-ID: <20231111090459.605791-2-e@80x24.org> (raw)
In-Reply-To: <20231111090459.605791-1-e@80x24.org>
When learning and injecting new messages ham, we want to avoid
wasting cycles importing the same message into an inbox twice
(once for the To/Cc match and once for the List-Id match). Our
existing %seen hash turned out to be ineffective since
PublicInbox::Inbox refs get re-blessed to PublicInbox::InboxWritable.
So we stop letting class name influence the hash key for tracking by
using the reference address instead. We can get the reference address
by performing an arithmetic operation (+ 0) instead of having to
pay the cost of importing Scalar::Util::refaddr.
---
script/public-inbox-learn | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/script/public-inbox-learn b/script/public-inbox-learn
index 54d31cb6..8069d919 100755
--- a/script/public-inbox-learn
+++ b/script/public-inbox-learn
@@ -110,12 +110,12 @@ if ($train eq 'spam' || ($train eq 'rm' && $opt{all})) {
my %seen;
while (my ($addr, $ibx) = each %dests) {
next unless ref($ibx); # $ibx may be 0
- next if $seen{"$ibx"}++;
+ next if $seen{0 + $ibx}++;
remove_or_add($ibx, $train, $mime, $addr);
}
my $dests = PublicInbox::MDA->inboxes_for_list_id($pi_cfg, $mime);
for my $ibx (@$dests) {
- next if $seen{"$ibx"}++;
+ next if $seen{0 + $ibx}++;
remove_or_add($ibx, $train, $mime, $ibx->{-primary_address});
}
}
next prev parent reply other threads:[~2023-11-11 9:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-11 9:04 [PATCH 0/4] support publicinboxImport.dropUniqueUnsubscribe Eric Wong
2023-11-11 9:04 ` Eric Wong [this message]
2023-11-11 9:04 ` [PATCH 2/4] mda|learn|watch: support dropUniqueUnsubscribe config Eric Wong
2023-11-11 9:04 ` [PATCH 3/4] mda: fix and test some usage problems Eric Wong
2023-11-11 9:04 ` [PATCH 4/4] doc: update README.unsubscribe 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=20231111090459.605791-2-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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
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).