about summary refs log tree commit homepage
path: root/lib/PublicInbox/NNTPD.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-12-04 22:03:45 +0000
committerEric Wong <e@80x24.org>2020-12-05 21:41:52 +0000
commit0a80d0c2e723213e3981d2d6ef0de7cee60ee50c (patch)
treea7a00f99a4e2d51153723da1861c8e2979cc17cb /lib/PublicInbox/NNTPD.pm
parent9356ec0cc5afc95a8fd398ddf898942ef0acdb74 (diff)
downloadpublic-inbox-0a80d0c2e723213e3981d2d6ef0de7cee60ee50c.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/NNTPD.pm')
-rw-r--r--lib/PublicInbox/NNTPD.pm9
1 files changed, 7 insertions, 2 deletions
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) ];