]> Sergey Matveev's repositories - public-inbox.git/commitdiff
inbox: do not waste hash slot on httpbackend_limiter
authorEric Wong <e@80x24.org>
Wed, 22 Sep 2021 02:24:33 +0000 (02:24 +0000)
committerEric Wong <e@80x24.org>
Wed, 22 Sep 2021 05:21:22 +0000 (05:21 +0000)
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

index 6cd20ec0b0418a088785e8ac0e70a94f0419688e..20f8c88489fcb8057e43817eef238c5e9fe9e3a8 100644 (file)
@@ -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;
        };