From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id DE7E31F543 for ; Wed, 24 Apr 2024 06:44:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1713941087; bh=gWypDez7Ig6yWhpPv9BNSroVWmFF+byspIn4WHgEu2c=; h=From:To:Subject:Date:In-Reply-To:References:From; b=GG9JIMh7bbzMTkJMD2DZH6Jd43ZHY3FXu+qzMXcd8xJyPCWzXsCmijJAIhlTP0qlK z0UomA2QtqN9x91UmKufPEwCvA5+G1An1yk5ruolDY7zqEomKHUlPzoMjm+N6anoLr 1sN62TCTQeE5+D1s+1OyiEXGuSfmr7L6KZZTejes= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/5] mbox: hoist out refill_result_ids Date: Wed, 24 Apr 2024 06:44:46 +0000 Message-ID: <20240424064447.523799-5-e@80x24.org> In-Reply-To: <20240424064447.523799-1-e@80x24.org> References: <20240424064447.523799-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This makes upcoming changes easier to understand. --- 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 {