dumping ground for random patches and texts
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH 4/8] mbox: hoist out refill_result_ids
Date: Wed, 24 Apr 2024 01:34:16 +0000	[thread overview]
Message-ID: <20240424013420.476353-4-e@80x24.org> (raw)
In-Reply-To: <20240424013420.476353-1-e@80x24.org>

---
 lib/PublicInbox/Mbox.pm | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm
index 52f88ae3..ac565df9 100644
--- a/lib/PublicInbox/Mbox.pm
+++ b/lib/PublicInbox/Mbox.pm
@@ -175,6 +175,17 @@ sub mbox_all_ids {
 	PublicInbox::MboxGz::mbox_gz($ctx, \&all_ids_cb, 'all');
 }
 
+sub refill_result_ids ($) {
+	my ($ctx) = @_;
+	# refill result set, deprioritize since there's many results
+	my $srch = $ctx->{ibx}->isrch or return $ctx->gone('search');
+	my $mset = $srch->mset($ctx->{query}, $ctx->{qopts});
+	my $size = $mset->size or return;
+	$ctx->{qopts}->{offset} += $size;
+	$ctx->{ids} = $srch->mset_to_artnums($mset, $ctx->{qopts});
+	$ctx->{-low_prio} = 1; # true
+}
+
 sub results_cb {
 	my ($ctx) = @_;
 	my $over = $ctx->{ibx}->over or return $ctx->gone('over');
@@ -183,13 +194,7 @@ sub results_cb {
 			my $smsg = $over->get_art($num) or next;
 			return $smsg;
 		}
-		# refill result set, deprioritize since there's many results
-		my $srch = $ctx->{ibx}->isrch or return $ctx->gone('search');
-		my $mset = $srch->mset($ctx->{query}, $ctx->{qopts});
-		my $size = $mset->size or return;
-		$ctx->{qopts}->{offset} += $size;
-		$ctx->{ids} = $srch->mset_to_artnums($mset, $ctx->{qopts});
-		$ctx->{-low_prio} = 1;
+		refill_result_ids($ctx) or return; # refill ctx->{ids}
 	}
 }
 
@@ -202,19 +207,10 @@ sub results_thread_cb {
 			my $smsg = $over->get_art($num) or next;
 			return $smsg;
 		}
+		next if $over->expand_thread($ctx); # refills ctx->{xids}
 
-		# refills ctx->{xids}
-		next if $over->expand_thread($ctx);
-
-		# refill result set, deprioritize since there's many results
-		my $srch = $ctx->{ibx}->isrch or return $ctx->gone('search');
-		my $mset = $srch->mset($ctx->{query}, $ctx->{qopts});
-		my $size = $mset->size or return;
-		$ctx->{qopts}->{offset} += $size;
-		$ctx->{ids} = $srch->mset_to_artnums($mset, $ctx->{qopts});
-		$ctx->{-low_prio} = 1;
+		refill_result_ids($ctx) or return; # refill ctx->{ids}
 	}
-
 }
 
 sub mbox_all {

  parent reply	other threads:[~2024-04-24  1:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-24  1:34 [PATCH 1/8] searchview: get rid of unused adump callback arg Eric Wong
2024-04-24  1:34 ` [PATCH 2/8] xap_helper.h: remove _SC_NPROCESSORS_ONLN default Eric Wong
2024-04-24  1:34 ` [PATCH 3/8] xap_helper: drop terms+data from `mset' command Eric Wong
2024-04-24  1:34 ` Eric Wong [this message]
2024-04-24  1:34 ` [PATCH 5/8] www: start wiring up search to use async xap_helper Eric Wong
2024-04-24  1:34 ` [PATCH 6/8] mset: mbox Eric Wong
2024-04-24  1:34 ` [PATCH 7/8] WIP thread bad mbox Eric Wong
2024-04-24  1:34 ` [PATCH 8/8] mbox: fixup Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240424013420.476353-4-e@80x24.org \
    --to=e@80x24.org \
    --cc=spew@80x24.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).