dumping ground for random patches and texts
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] no recursion
Date: Wed,  6 Dec 2023 20:39:49 +0000	[thread overview]
Message-ID: <20231206203949.1951171-1-e@80x24.org> (raw)

---
 lib/PublicInbox/CodeSearchIdx.pm | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/lib/PublicInbox/CodeSearchIdx.pm b/lib/PublicInbox/CodeSearchIdx.pm
index 20aac584..967933f2 100644
--- a/lib/PublicInbox/CodeSearchIdx.pm
+++ b/lib/PublicInbox/CodeSearchIdx.pm
@@ -909,21 +909,23 @@ sub prep_alternate_read { # run_git cb for config extensions.objectFormat
 
 sub prep_alternate_start {
 	my ($self, $git, $run_prune) = @_;
-	my $o = $git->git_path('objects');
+	local $self->{xdb};
+	my ($o, $n, @ids, @fmt);
+start:
+	$o = $git->git_path('objects');
 	while (!-d $o) {
 		$git = shift(@PRUNEQ) // return;
 		$o = $git->git_path('objects');
 	}
-	my $n = git_dir_hash($git->{git_dir}) % scalar(@RDONLY_XDB);
-	local $self->{xdb} = $RDONLY_XDB[$n] // croak("BUG: no shard[$n]");
-	my @ids = $self->docids_by_postlist('P'.$git->{git_dir});
-	my @fmt = @ids ? xap_terms('H', $self->{xdb}, $ids[0]) : ();
+	$n = git_dir_hash($git->{git_dir}) % scalar(@RDONLY_XDB);
+	$self->{xdb} = $RDONLY_XDB[$n] // croak("BUG: no shard[$n]");
+	@ids = $self->docids_by_postlist('P'.$git->{git_dir});
+	@fmt = @ids ? xap_terms('H', $self->{xdb}, $ids[0]) : ();
 	@fmt > 1 and warn "BUG? multi `H' for shard[$n] #$ids[0]: @fmt";
 
 	if (@fmt) { # cache hit
-		@PRUNEQ and
-			prep_alternate_start($self, shift(@PRUNEQ), $run_prune);
 		prep_alternate_end $o, $fmt[0];
+		$git = shift(@PRUNEQ) and goto start;
 	} else { # compatibility w/ early cidx format
 		run_git([qw(config extensions.objectFormat)], { quiet => 1 },
 			\&prep_alternate_read, $self, $git, $o, $ids[0], $n,

                 reply	other threads:[~2023-12-06 20:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20231206203949.1951171-1-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).