]> Sergey Matveev's repositories - public-inbox.git/commitdiff
treewide: ditch inbox->recent method
authorEric Wong <e@80x24.org>
Mon, 29 Aug 2022 09:26:38 +0000 (09:26 +0000)
committerEric Wong <e@80x24.org>
Mon, 29 Aug 2022 19:05:49 +0000 (19:05 +0000)
It's a needless wrapper, nowadays.  Originally, ->over was added
on experimental basis to optimize for /$INBOX/ where Xapian
->search is slower on gigantic (LKML-sized) inboxes.

Nowadays with extindex, ->over is here to stay given NNTP and
IMAP both benefit from it.  So reduce the interpreter stack
overhead and just access ->over directly.

lxs->recent was never used outside of tests, anyways.

And while we're in the area, avoid needlessly bumping the
refcount of $ctx->{ibx} in View::paginate_recent.

lib/PublicInbox/ExtSearch.pm
lib/PublicInbox/Inbox.pm
lib/PublicInbox/LeiSavedSearch.pm
lib/PublicInbox/LeiXSearch.pm
lib/PublicInbox/View.pm
t/convert-compact.t
t/indexlevels-mirror.t
t/lei_xsearch.t
t/replace.t
t/v1-add-remove-add.t
t/v2-add-remove-add.t

index 3eb864a2074e5ac8686091908df60a571db371f2..a69c0e76a8afcbd1e9e7248e2dc4b1ca3d5455dd 100644 (file)
@@ -125,7 +125,6 @@ no warnings 'once';
 *smsg_by_mid = \&PublicInbox::Inbox::smsg_by_mid;
 *msg_by_mid = \&PublicInbox::Inbox::msg_by_mid;
 *modified = \&PublicInbox::Inbox::modified;
-*recent = \&PublicInbox::Inbox::recent;
 
 *max_git_epoch = *nntp_usable = *msg_by_path = \&mm; # undef
 *isrch = \&search;
index acd7f33843a7654b6895f70bfbd1ea9bdd441dea..8ac7eb302a0c6ed9ef7b9b97f53888bcc115d866 100644 (file)
@@ -351,11 +351,6 @@ sub msg_by_mid ($$) {
        $smsg ? msg_by_smsg($self, $smsg) : msg_by_path($self, mid2path($mid));
 }
 
-sub recent {
-       my ($self, $opts, $after, $before) = @_;
-       $self->over->recent($opts, $after, $before);
-}
-
 sub modified {
        my ($self) = @_;
        if (my $over = $self->over) {
index 1d13aef6728a6a5ebcbcd942a93630f61872e1ed..ed92bfd11fe1c4b0a80342a702bdece58cde1b46 100644 (file)
@@ -299,7 +299,6 @@ no warnings 'once';
 *smsg_by_mid = \&PublicInbox::Inbox::smsg_by_mid;
 *msg_by_mid = \&PublicInbox::Inbox::msg_by_mid;
 *modified = \&PublicInbox::Inbox::modified;
-*recent = \&PublicInbox::Inbox::recent;
 *max_git_epoch = *nntp_usable = *msg_by_path = \&mm; # undef
 *isrch = *search = \&mm; # TODO
 *DESTROY = \&pause_dedupe;
index 6f8770191ee6a28b36b1f7f631cbb9ebc7b26e86..90cb83b989feb6c1099b1213ff2937c2a0b38c2a 100644 (file)
@@ -103,13 +103,6 @@ sub smsg_for {
        $smsg;
 }
 
-sub recent {
-       my ($self, $qstr, $opt) = @_;
-       $opt //= {};
-       $opt->{relevance} //= -2;
-       $self->mset($qstr //= 'z:1..', $opt);
-}
-
 sub over {}
 
 sub _check_mset_limit ($$$) {
index 9846fa4779c6286611bae99301cd68b39b4c5e15..466ec6cfdad1c0677211878498d0db288e170247 100644 (file)
@@ -1237,12 +1237,11 @@ sub paginate_recent ($$) {
        $t =~ s/\A([0-9]{8,14})-// and $after = str2ts($1);
        $t =~ /\A([0-9]{8,14})\z/ and $before = str2ts($1);
 
-       my $ibx = $ctx->{ibx};
-       my $msgs = $ibx->recent($opts, $after, $before);
+       my $msgs = $ctx->{ibx}->over->recent($opts, $after, $before);
        my $nr = scalar @$msgs;
        if ($nr < $lim && defined($after)) {
                $after = $before = undef;
-               $msgs = $ibx->recent($opts);
+               $msgs = $ctx->{ibx}->over->recent($opts);
                $nr = scalar @$msgs;
        }
        my $more = $nr == $lim;
index 7270cab082838539e81cf2d6294abd85a3a29309..def09567fefdcdabf8d48100dd5ef1841d2700dd 100644 (file)
@@ -101,7 +101,7 @@ foreach (@xdir) {
        is($st[2] & 07777, -f _ ? 0444 : 0755,
                'sharedRepository respected after v2 compact');
 }
-my $msgs = $ibx->recent({limit => 1000});
+my $msgs = $ibx->over->recent({limit => 1000});
 is($msgs->[0]->{mid}, 'a-mid@b', 'message exists in history');
 is(scalar @$msgs, 1, 'only one message in history');
 
index ac85643d0423e82bcd7488fc1989f5f312960bc5..463b35becc49ac3ac79be30cc625a049f744b1eb 100644 (file)
@@ -41,7 +41,7 @@ my $import_index_incremental = sub {
                inboxdir => $ibx->{inboxdir},
                indexlevel => $level
        });
-       my $msgs = $ro_master->recent;
+       my $msgs = $ro_master->over->recent;
        is(scalar(@$msgs), 1, 'only one message in master, so far');
        is($msgs->[0]->{mid}, 'm@1', 'first message in master indexed');
 
@@ -71,7 +71,7 @@ my $import_index_incremental = sub {
                inboxdir => $mirror,
                indexlevel => $level,
        });
-       $msgs = $ro_mirror->recent;
+       $msgs = $ro_mirror->over->recent;
        is(scalar(@$msgs), 1, 'only one message, so far');
        is($msgs->[0]->{mid}, 'm@1', 'read first message');
 
@@ -83,7 +83,7 @@ my $import_index_incremental = sub {
        # mirror updates
        is(xsys('git', "--git-dir=$fetch_dir", qw(fetch -q)), 0, 'fetch OK');
        ok(run_script([qw(-index -j0), $mirror]), "v$v index mirror again OK");
-       $msgs = $ro_mirror->recent;
+       $msgs = $ro_mirror->over->recent;
        is(scalar(@$msgs), 2, '2nd message seen in mirror');
        is_deeply([sort { $a cmp $b } map { $_->{mid} } @$msgs],
                ['m@1','m@2'], 'got both messages in mirror');
@@ -91,7 +91,7 @@ my $import_index_incremental = sub {
        # incremental index master (required for v1)
        ok(run_script([qw(-index -j0), $ibx->{inboxdir}, "-L$level"]),
                'index master OK');
-       $msgs = $ro_master->recent;
+       $msgs = $ro_master->over->recent;
        is(scalar(@$msgs), 2, '2nd message seen in master');
        is_deeply([sort { $a cmp $b } map { $_->{mid} } @$msgs],
                ['m@1','m@2'], 'got both messages in master');
@@ -120,7 +120,7 @@ my $import_index_incremental = sub {
        # sync the mirror
        is(xsys('git', "--git-dir=$fetch_dir", qw(fetch -q)), 0, 'fetch OK');
        ok(run_script([qw(-index -j0), $mirror]), "v$v index mirror again OK");
-       $msgs = $ro_mirror->recent;
+       $msgs = $ro_mirror->over->recent;
        is(scalar(@$msgs), 1, '2nd message gone from mirror');
        is_deeply([map { $_->{mid} } @$msgs], ['m@1'],
                'message unavailable in mirror');
index d9ddb2977c17114ae8f7ce78fabb2e5fd38375e9..fabceb418b03ea2933036a6a61b3fbf8542ae462 100644 (file)
@@ -61,7 +61,7 @@ for my $mi ($mset->items) {
 }
 is(scalar(@msgs), $nr, 'smsgs retrieved for all');
 
-$mset = $lxs->recent(undef, { limit => 1 });
+$mset = $lxs->mset('z:1..', { relevance => -2, limit => 1 });
 is($mset->size, 1, 'one result');
 
 my @ibxish = $lxs->locals;
index 626cbe9b091bedcc9055c603a35fc262a4f29c81..0e1213993f0a80f6842cb21cc18c5f7ab3899bdc 100644 (file)
@@ -49,7 +49,7 @@ EOF
        $im->done;
        my $thread_a = $ibx->over->get_thread('replace@example.com');
 
-       my %before = map {; delete($_->{blob}) => $_ } @{$ibx->recent};
+       my %before = map {; delete($_->{blob}) => $_ } @{$ibx->over->recent};
        my $reject = PublicInbox::Eml->new($orig->as_string);
        foreach my $mid (['<replace@example.com>', '<extra@example.com>'],
                                [], ['<replaced@example.com>']) {
@@ -126,7 +126,7 @@ EOF
        }
 
        # check overview matches:
-       my %after = map {; delete($_->{blob}) => $_ } @{$ibx->recent};
+       my %after = map {; delete($_->{blob}) => $_ } @{$ibx->over->recent};
        my @before_blobs = keys %before;
        foreach my $blob (@before_blobs) {
                delete $before{$blob} if delete $after{$blob};
index a94bf7fd048743deaf2bfb02d9032d51e4ba5034..ae045dfa2d4d3af8e7d7c4dac0128572161213e8 100644 (file)
@@ -32,7 +32,7 @@ ok($im->add($mime), 'message added again');
 $im->done;
 my $rw = PublicInbox::SearchIdx->new($ibx, 1);
 $rw->index_sync;
-my $msgs = $ibx->recent({limit => 10});
+my $msgs = $ibx->over->recent({limit => 10});
 is($msgs->[0]->{mid}, 'a-mid@b', 'message exists in history');
 is(scalar @$msgs, 1, 'only one message in history');
 is($ibx->mm->num_for('a-mid@b'), 2, 'exists with second article number');
index 579cdcb679fea75c7f71fe5369278a54ba0cdd10..6affc83079fdcc809ff6fbdafb056dee92937f05 100644 (file)
@@ -32,7 +32,7 @@ ok($im->add($mime), 'message added');
 ok($im->remove($mime), 'message removed');
 ok($im->add($mime), 'message added again');
 $im->done;
-my $msgs = $ibx->recent({limit => 1000});
+my $msgs = $ibx->over->recent({limit => 1000});
 is($msgs->[0]->{mid}, 'a-mid@b', 'message exists in history');
 is(scalar @$msgs, 1, 'only one message in history');