]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
index: move {D} (delete state) to $self
authorEric Wong <e@80x24.org>
Fri, 10 Jan 2025 23:18:59 +0000 (23:18 +0000)
committerEric Wong <e@80x24.org>
Tue, 14 Jan 2025 04:45:35 +0000 (04:45 +0000)
The {D} delete state is short-lived and may have its scope
limited via `local', so take another step towards reducing
internal data structures.

lib/PublicInbox/SearchIdx.pm
lib/PublicInbox/V2Writable.pm

index 9771633d558697d7fda8b1777bc6c23e40b123ac..0e84a6a660bf04a56e97ae693eaab5d90f5d2384 100644 (file)
@@ -914,7 +914,7 @@ sub v1_process_stack ($$$) {
        local $self->{latest_cmt};
 
        $self->{mm}->{dbh}->begin_work;
-       if (my @leftovers = keys %{delete($sync->{D}) // {}}) {
+       if (my @leftovers = keys %{delete($self->{D}) // {}}) {
                warn('W: unindexing '.scalar(@leftovers)." leftovers\n");
                for my $oid (@leftovers) {
                        last if $self->{quit};
@@ -945,7 +945,7 @@ sub v1_process_stack ($$$) {
 
 sub log2stack ($$$$) {
        my ($self, $sync, $git, $range) = @_;
-       my $D = $sync->{D}; # OID_BIN => NR (if reindexing, undef otherwise)
+       my $D = $self->{D}; # OID_BIN => NR (if reindexing, undef otherwise)
        my ($add, $del);
        if ($sync->{ibx}->version == 1) {
                my $path = $hex.'{2}/'.$hex.'{38}';
@@ -1006,7 +1006,7 @@ sub prepare_stack ($$$) {
                $git->qx(qw(rev-parse -q --verify), "$range^0");
                return PublicInbox::IdxStack->new->read_prepare if $?;
        }
-       $sync->{D} = $sync->{reindex} ? {} : undef; # OID_BIN => NR
+       local $self->{D} = $sync->{reindex} ? {} : undef; # OID_BIN => NR
        log2stack($self, $sync, $git, $range);
 }
 
index ff4e973a108cf644095f0b188bb7bcc861917681..6ab9cbaf4a4d22de4901efeab1190772f8b14f2d 100644 (file)
@@ -914,6 +914,7 @@ sub sync_prepare ($$) {
        my $regen_max = 0;
        my $head = $sync->{ibx}->{ref_head} || 'HEAD';
        my $pfx;
+       local $self->{D}; # delete state
        if ($pr) {
                ($pfx) = ($sync->{ibx}->{inboxdir} =~ m!([^/]+)\z!g);
                $pfx //= $sync->{ibx}->{inboxdir};
@@ -958,7 +959,7 @@ sub sync_prepare ($$) {
                # We intentionally do NOT use {D} in the non-reindex case
                # because we want NNTP article number gaps from unindexed
                # messages to show up in mirrors, too.
-               $sync->{D} //= $sync->{reindex} ? {} : undef; # OID_BIN => NR
+               $self->{D} //= $sync->{reindex} ? {} : undef; # OID_BIN => NR
                my $stk = log2stack($self, $sync, $git, $range);
                return 0 if $self->{quit};
                my $nr = $stk ? $stk->num_records : 0;
@@ -971,7 +972,7 @@ sub sync_prepare ($$) {
 
        # XXX this should not happen unless somebody bypasses checks in
        # our code and blindly injects "d" file history into git repos
-       if (my @leftovers = keys %{delete($sync->{D}) // {}}) {
+       if (my @leftovers = keys %{delete($self->{D}) // {}}) {
                warn('W: unindexing '.scalar(@leftovers)." leftovers\n");
                local $self->{current_info} = 'leftover ';
                my $unindex_oid = $self->can('unindex_oid');