From 7ac0b9ceb450c8c4b8117aca59213d7ae928e799 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 10 Jan 2025 23:20:14 +0000 Subject: [PATCH] (ext)index: move {ranges} to $self Another field we can trivially `local'-ize in our quest to eliminate the clumsy $sync structure. --- lib/PublicInbox/ExtSearchIdx.pm | 1 + lib/PublicInbox/V2Writable.pm | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/ExtSearchIdx.pm b/lib/PublicInbox/ExtSearchIdx.pm index 7ccfb1db5..c0eae0e3c 100644 --- a/lib/PublicInbox/ExtSearchIdx.pm +++ b/lib/PublicInbox/ExtSearchIdx.pm @@ -403,6 +403,7 @@ sub _sync_inbox ($$$) { local $self->{epoch_max}; my $v = $ibx->version; local $self->{todo}; # set by sync_prepare + local $self->{ranges}; local $self->{unindexed}; if ($v == 2) { $self->{epoch_max} = $ibx->max_git_epoch // return; diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index 6b43bac14..ded3f2c1f 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -845,17 +845,18 @@ sub last_commits { # returns a revision range for git-log(1) sub log_range ($$$) { my ($sync, $unit, $tip) = @_; - my $opt = $sync->{self}->{-opt}; + my $self = $sync->{self}; + my $opt = $self->{-opt}; my $pr = $opt->{-progress} if (($opt->{verbose} || 0) > 1); my $i = $unit->{epoch}; - my $cur = $sync->{ranges}->[$i] or do { + my $cur = $self->{ranges}->[$i] or do { $pr->("$i.git indexing all of $tip\n") if $pr; return $tip; # all of it }; # fast equality check to avoid (v)fork+execve overhead if ($cur eq $tip) { - $sync->{ranges}->[$i] = undef; + $self->{ranges}->[$i] = undef; return; } @@ -867,7 +868,7 @@ sub log_range ($$$) { my $n = $git->qx(qw(rev-list --count), $range); chomp($n); if ($n == 0) { - $sync->{ranges}->[$i] = undef; + $self->{ranges}->[$i] = undef; $pr->("$i.git has nothing new\n") if $pr; return; # nothing to do } @@ -907,7 +908,7 @@ sub artnum_max { $_[0]->{mm}->num_highwater } sub sync_prepare ($$) { my ($self, $sync) = @_; - $sync->{ranges} = sync_ranges($self, $sync); + $self->{ranges} = sync_ranges($self, $sync); my $pr = $self->{-opt}->{-progress}; my $regen_max = 0; my $head = $self->{ibx}->{ref_head} || 'HEAD'; @@ -1234,6 +1235,7 @@ sub index_sync { local $self->{reindex} = $opt->{reindex}; local $self->{mm_tmp}; local $self->{todo}; # sync_prepare + local $self->{ranges}; local $self->{unindexed}; my $sync = { self => $self, ibx => $self->{ibx} }; my $quit = PublicInbox::SearchIdx::quit_cb $self; -- 2.47.3