]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
(ext)index: move {ranges} to $self
authorEric Wong <e@80x24.org>
Fri, 10 Jan 2025 23:20:14 +0000 (23:20 +0000)
committerEric Wong <e@80x24.org>
Tue, 14 Jan 2025 04:45:48 +0000 (04:45 +0000)
Another field we can trivially `local'-ize in our quest to
eliminate the clumsy $sync structure.

lib/PublicInbox/ExtSearchIdx.pm
lib/PublicInbox/V2Writable.pm

index 7ccfb1db550c628cdd122b6a2b5d515eccec46ae..c0eae0e3c652663ce57e728cde0708e4c3fe015f 100644 (file)
@@ -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;
index 6b43bac1468b89d5ea7b942b6823253210a0ec13..ded3f2c1f1b27ec03b0b10e445ff06e999935d4f 100644 (file)
@@ -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;