]> Sergey Matveev's repositories - public-inbox.git/commitdiff
inbox + search: use 5.10.1 and do some golfing
authorEric Wong <e@80x24.org>
Sat, 16 Oct 2021 01:01:02 +0000 (01:01 +0000)
committerEric Wong <e@80x24.org>
Sat, 16 Oct 2021 01:42:55 +0000 (01:42 +0000)
Some yak-shaving while I try to track down other bugs...

lib/PublicInbox/Inbox.pm
lib/PublicInbox/Search.pm

index 74b8a74f8856e7992fd29b742ff89f75d1dddaf3..b7b71268187e86ce8f6f583e5391d645da8fb7f5 100644 (file)
@@ -4,6 +4,7 @@
 # Represents a public-inbox (which may have multiple mailing addresses)
 package PublicInbox::Inbox;
 use strict;
+use v5.10.1;
 use PublicInbox::Git;
 use PublicInbox::MID qw(mid2path);
 use PublicInbox::Eml;
@@ -293,17 +294,15 @@ sub msg_by_smsg ($$) {
 
        # ghosts may have undef smsg (from SearchThread.node) or
        # no {blob} field
-       return unless defined $smsg;
-       defined(my $blob = $smsg->{blob}) or return;
-
-       $self->git->cat_file($blob);
+       $smsg // return;
+       $self->git->cat_file($smsg->{blob} // return);
 }
 
 sub smsg_eml {
        my ($self, $smsg) = @_;
        my $bref = msg_by_smsg($self, $smsg) or return;
        my $eml = PublicInbox::Eml->new($bref);
-       $smsg->populate($eml) unless exists($smsg->{num}); # v1 w/o SQLite
+       $smsg->{num} // $smsg->populate($eml);
        $eml;
 }
 
@@ -313,7 +312,7 @@ sub smsg_by_mid ($$) {
        my $smsg;
        if (my $mm = $self->mm) {
                # favor the Message-ID we used for the NNTP article number:
-               defined(my $num = $mm->num_for($mid)) or return;
+               my $num = $mm->num_for($mid) // return;
                $smsg = $over->get_art($num);
        } else {
                my ($id, $prev);
index 145fb56ce75006d167efc541257aa05f37b5cd5f..600e6400d4b672bb477a236eff12c27b9c3e4f51 100644 (file)
@@ -5,6 +5,7 @@
 # Read-only search interface for use by the web and NNTP interfaces
 package PublicInbox::Search;
 use strict;
+use v5.10.1;
 use parent qw(Exporter);
 our @EXPORT_OK = qw(retry_reopen int_val get_pct xap_terms);
 use List::Util qw(max);
@@ -398,12 +399,10 @@ sub retry_reopen {
        my ($self, $cb, @arg) = @_;
        for my $i (1..10) {
                if (wantarray) {
-                       my @ret;
-                       eval { @ret = $cb->($self, @arg) };
+                       my @ret = eval { $cb->($self, @arg) };
                        return @ret unless $@;
                } else {
-                       my $ret;
-                       eval { $ret = $cb->($self, @arg) };
+                       my $ret = eval { $cb->($self, @arg) };
                        return $ret unless $@;
                }
                # Exception: The revision being read has been discarded -