From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/5] nntp: xref_by_tc: simplify slightly
Date: Fri, 4 Dec 2020 22:03:45 +0000 [thread overview]
Message-ID: <20201204220349.4408-2-e@80x24.org> (raw)
In-Reply-To: <20201204220349.4408-1-e@80x24.org>
We can invalidate ibx->{newsgroup} at config load-time to avoid
having to check ibx->{newsgroup} validity in To/Cc: matching.
This saves us some hash lookups in all cases.
---
lib/PublicInbox/NNTP.pm | 3 +--
lib/PublicInbox/NNTPD.pm | 9 +++++++--
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index e0916011..6728f9c5 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -422,14 +422,13 @@ sub header_append ($$$) {
sub xref_by_tc ($$$) {
my ($xref, $pi_cfg, $smsg) = @_;
my $by_addr = $pi_cfg->{-by_addr};
- my $groups = $pi_cfg->{-by_newsgroup};
my $mid = $smsg->{mid};
for my $f (qw(to cc)) {
my @ibxs = map {
$by_addr->{lc($_)} // ()
} (PublicInbox::Address::emails($smsg->{$f} // ''));
for my $ibx (@ibxs) {
- $groups->{my $ngname = $ibx->{newsgroup}} or next;
+ my $ngname = $ibx->{newsgroup} // next;
next if defined $xref->{$ngname};
$xref->{$ngname} = eval { $ibx->mm->num_for($mid) };
}
diff --git a/lib/PublicInbox/NNTPD.pm b/lib/PublicInbox/NNTPD.pm
index 967850e9..03c56db3 100644
--- a/lib/PublicInbox/NNTPD.pm
+++ b/lib/PublicInbox/NNTPD.pm
@@ -38,13 +38,18 @@ sub refresh_groups {
my $groups = $pi_config->{-by_newsgroup}; # filled during each_inbox
$pi_config->each_inbox(sub {
my ($ibx) = @_;
- my $ngname = $ibx->{newsgroup} // return;
- if ($ibx->nntp_usable) { # only valid if msgmap and over works
+ my $ngname = $ibx->{newsgroup};
+ if (defined($ngname) && $ibx->nntp_usable) {
+ # only valid if msgmap and over works
# preload to avoid fragmentation:
$ibx->description;
$ibx->base_url;
} else {
delete $groups->{$ngname};
+ delete $ibx->{newsgroup};
+ # Note: don't be tempted to delete more for memory
+ # savings just yet: NNTP, IMAP, and WWW may all
+ # run in the same process someday.
}
});
$self->{groupnames} = [ sort(keys %$groups) ];
next prev parent reply other threads:[~2020-12-04 22:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-04 22:03 [PATCH 0/5] more ->ALL usage Eric Wong
2020-12-04 22:03 ` Eric Wong [this message]
2020-12-04 22:03 ` [PATCH 2/5] nntp: small speed up for multi-line responses Eric Wong
2020-12-04 22:03 ` [PATCH 3/5] search: remove mdocid export Eric Wong
2020-12-04 22:03 ` [PATCH 4/5] newswww: use ->ALL to avoid O(n) inbox scan Eric Wong
2020-12-04 22:03 ` [PATCH 5/5] extmsg: use ->ALL for "global" MID lookups 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: http://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=20201204220349.4408-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).