From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 8F5971FB07 for ; Wed, 22 Sep 2021 02:24:35 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 5/7] inbox: do not waste hash slot on httpbackend_limiter Date: Wed, 22 Sep 2021 02:24:33 +0000 Message-Id: <20210922022435.17835-6-e@80x24.org> In-Reply-To: <20210922022435.17835-1-e@80x24.org> References: <20210922022435.17835-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: A few dozen bytes saved here can add up when we have thousands of inboxes. It also makes Data::Dumper debug output a bit cleaner. --- lib/PublicInbox/Inbox.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index 6cd20ec0..20f8c884 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -126,11 +126,12 @@ sub version { sub git_epoch { my ($self, $epoch) = @_; # v2-only, callers always supply $epoch - $self->{"$epoch.git"} ||= do { + $self->{"$epoch.git"} //= do { my $git_dir = "$self->{inboxdir}/git/$epoch.git"; return unless -d $git_dir; my $g = PublicInbox::Git->new($git_dir); - $g->{-httpbackend_limiter} = $self->{-httpbackend_limiter}; + my $lim = $self->{-httpbackend_limiter}; + $g->{-httpbackend_limiter} = $lim if $lim; # caller must manually cleanup when done $g; }; @@ -138,11 +139,12 @@ sub git_epoch { sub git { my ($self) = @_; - $self->{git} ||= do { + $self->{git} //= do { my $git_dir = $self->{inboxdir}; $git_dir .= '/all.git' if $self->version == 2; my $g = PublicInbox::Git->new($git_dir); - $g->{-httpbackend_limiter} = $self->{-httpbackend_limiter}; + my $lim = $self->{-httpbackend_limiter}; + $g->{-httpbackend_limiter} = $lim if $lim; _cleanup_later($self); $g; };