]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
(ext)index: move {unindexed} to $self
authorEric Wong <e@80x24.org>
Fri, 10 Jan 2025 23:20:13 +0000 (23:20 +0000)
committerEric Wong <e@80x24.org>
Tue, 14 Jan 2025 04:45:45 +0000 (04:45 +0000)
As with most things that were formerly in $sync, we can just
rely on `local' to flatten the data structure graph and work
towards eliminating $sync.

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

index 807666fc89f47878c93e74596ef551ab10fc58e3..7ccfb1db550c628cdd122b6a2b5d515eccec46ae 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->{unindexed};
        if ($v == 2) {
                $self->{epoch_max} = $ibx->max_git_epoch // return;
                sync_prepare($self, $sync); # or return # TODO: once MiscIdx is stable
index 548d8bde013d5f014fa0956da595d2a9c8bf9394..6b43bac1468b89d5ea7b942b6823253210a0ec13 100644 (file)
@@ -746,16 +746,14 @@ sub index_oid { # cat_async callback
        }
 
        # {unindexed} is unlikely
-       if (my $unindexed = $arg->{unindexed}) {
+       if (my $unindexed = $self->{unindexed}) {
                my $oidbin = pack('H*', $oid);
                my $u = $unindexed->{$oidbin};
                ($num, $mid0) = splice(@$u, 0, 2) if $u;
                if (defined $num) {
                        $self->{mm}->mid_set($num, $mid0);
-                       if (scalar(@$u) == 0) { # done with current OID
-                               delete $unindexed->{$oidbin};
-                               delete($arg->{unindexed}) if !keys(%$unindexed);
-                       }
+                       # done w/ current OID?
+                       delete $unindexed->{$oidbin} if !@$u;
                }
        }
        my $oidx = $self->{oidx};
@@ -1014,7 +1012,7 @@ sub unindex_oid ($$;$) { # git->cat_async callback
                return index_finalize($arg, 0);
        my $self = $arg->{self};
        local $self->{current_info} = "$self->{current_info} $oid";
-       my $unindexed = $self->{in_unindex} ? $arg->{unindexed} : undef;
+       my $unindexed = $self->{in_unindex} ? $self->{unindexed} : undef;
        my $mm = $self->{mm};
        my $mids = mids(PublicInbox::Eml->new($bref));
        undef $$bref;
@@ -1052,7 +1050,7 @@ sub git { $_[0]->{ibx}->git }
 sub unindex_todo ($$$) {
        my ($self, $sync, $unit) = @_;
        my $unindex_range = delete($unit->{unindex_range}) // return;
-       my $unindexed = $sync->{unindexed} //= {}; # $oidbin => [$num, $mid0]
+       my $unindexed = $self->{unindexed} //= {}; # $oidbin => [$num, $mid0]
        my $before = scalar keys %$unindexed;
        # order does not matter, here:
        my $fh = $unit->{git}->popen(qw(log --raw -r --no-notes --no-color
@@ -1236,6 +1234,7 @@ sub index_sync {
        local $self->{reindex} = $opt->{reindex};
        local $self->{mm_tmp};
        local $self->{todo}; # sync_prepare
+       local $self->{unindexed};
        my $sync = { self => $self, ibx => $self->{ibx} };
        my $quit = PublicInbox::SearchIdx::quit_cb $self;
        local $SIG{QUIT} = $quit;