]> Sergey Matveev's repositories - public-inbox.git/commitdiff
inbox: cloneurl: avoid undef to hash table value
authorEric Wong <e@80x24.org>
Sun, 26 Sep 2021 01:42:29 +0000 (01:42 +0000)
committerEric Wong <e@80x24.org>
Sun, 26 Sep 2021 01:43:35 +0000 (01:43 +0000)
This saves us some memory for the hash slot in the common case
the `cloneurl' file doesn't exist.

lib/PublicInbox/Inbox.pm

index 3ba92c997f2c669911e4f6667f5576ff1cd4c613..1d5fc708ad28b2649cf5a2460bfcbba96c8f3eeb 100644 (file)
@@ -216,11 +216,11 @@ sub description {
 
 sub cloneurl {
        my ($self) = @_;
-       ($self->{cloneurl} //= do {
+       $self->{cloneurl} // do {
                my $s = try_cat("$self->{inboxdir}/cloneurl");
                my @urls = split(/\s+/s, $s);
-               scalar(@urls) ? \@urls : undef
-       }) // [];
+               scalar(@urls) ? ($self->{cloneurl} = \@urls) : undef;
+       } // [];
 }
 
 sub base_url {