about summary refs log tree commit homepage
path: root/lib/PublicInbox/Inbox.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-09-28 23:11:06 +0000
committerEric Wong <e@80x24.org>2021-09-29 00:08:34 +0000
commitb9e7ecbbd53b97cfb9437a27e548d1df15d871b4 (patch)
tree058325dc76df1f16f5b3f34c30c1b5f2f42fc656 /lib/PublicInbox/Inbox.pm
parent7e5cea05f061e757f36b3eb9abcd285425365224 (diff)
downloadpublic-inbox-b9e7ecbbd53b97cfb9437a27e548d1df15d871b4.tar.gz
cloneurl, description, and base_url are no longer memoized.  The
non-$env form of base_url is rare in WWW, and is fast enough to
not require memoization.

cloneurl and description are now expired during cleanup,
allowing admins to change these files without restarting
(or SIGHUP).

-altid_map is no longer cached nor memoized at all, since the
endpoint(s) which hit it seem rarely accessed.

nntp_url and imap_url are now cached (instead of memoized) in
case an inbox is unvisited for a long time.  They remain cached
since the truthiness check gets called in every per-inbox HTML
page, which can potentially be expensive.
Diffstat (limited to 'lib/PublicInbox/Inbox.pm')
-rw-r--r--lib/PublicInbox/Inbox.pm21
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index 04b7d764..c525f4d1 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -33,7 +33,8 @@ sub do_cleanup {
         for my $git (@{$ibx->{-repo_objs}}) {
                 $live = 1 if $git->cleanup(1);
         }
-        delete @$ibx{qw(over mm)};
+        delete @$ibx{qw(over mm description cloneurl
+                        -altid_map -imap_url -nntp_url)};
         PublicInbox::DS::add_uniq_timer($ibx+0, 5, \&do_cleanup, $ibx) if $live;
 }
 
@@ -219,15 +220,13 @@ sub base_url {
                 return $url .= $self->{name} . '/';
         }
         # called from a non-PSGI environment (e.g. NNTP/POP3):
-        $self->{-base_url} ||= do {
-                my $url = $self->{url} // return undef;
-                $url = $url->[0] // return undef;
-                # expand protocol-relative URLs to HTTPS if we're
-                # not inside a web server
-                $url = "https:$url" if $url =~ m!\A//!;
-                $url .= '/' if $url !~ m!/\z!;
-                $url;
-        };
+        my $url = $self->{url} // return undef;
+        $url = $url->[0] // return undef;
+        # expand protocol-relative URLs to HTTPS if we're
+        # not inside a web server
+        substr($url, 0, 0, 'https:') if substr($url, 0, 2) eq '//';
+        $url .= '/' if substr($url, -1, 1) ne '/';
+        $url;
 }
 
 sub _x_url ($$$) {
@@ -350,7 +349,7 @@ sub modified {
 # (pathname is NOT public, but prefix is used for Xapian queries)
 sub altid_map ($) {
         my ($self) = @_;
-        $self->{-altid_map} //= eval {
+        eval {
                 require PublicInbox::AltId;
                 my $altid = $self->{altid} or return {};
                 my %h = map {;