From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 1178F1F8E0 for ; Fri, 24 Jul 2020 05:56:08 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 05/20] v2writable: move {autime} and {cotime} into $sync state Date: Fri, 24 Jul 2020 05:55:51 +0000 Message-Id: <20200724055606.27332-6-e@yhbt.net> In-Reply-To: <20200724055606.27332-1-e@yhbt.net> References: <20200724055606.27332-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: The V2Writable object may be long-lived, so it makes more sense to put the {autime} and {cotime} fields into the shorter-lived index_sync state. --- lib/PublicInbox/Smsg.pm | 8 ++++---- lib/PublicInbox/V2Writable.pm | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/PublicInbox/Smsg.pm b/lib/PublicInbox/Smsg.pm index 725d42062..aaf88f355 100644 --- a/lib/PublicInbox/Smsg.pm +++ b/lib/PublicInbox/Smsg.pm @@ -96,7 +96,7 @@ sub from_mitem { # for Import and v1 non-SQLite WWW code paths sub populate { - my ($self, $hdr, $v2w) = @_; + my ($self, $hdr, $sync) = @_; for my $f (qw(From To Cc Subject)) { my @all = $hdr->header($f); my $val = join(', ', @all); @@ -117,9 +117,9 @@ sub populate { } $self->{$f} = $val if $val ne ''; } - $v2w //= {}; - $self->{-ds} = [ my @ds = msg_datestamp($hdr, $v2w->{autime}) ]; - $self->{-ts} = [ my @ts = msg_timestamp($hdr, $v2w->{cotime}) ]; + $sync //= {}; + $self->{-ds} = [ my @ds = msg_datestamp($hdr, $sync->{autime}) ]; + $self->{-ts} = [ my @ts = msg_timestamp($hdr, $sync->{cotime}) ]; $self->{ds} //= $ds[0]; # no zone $self->{ts} //= $ts[0]; diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index c896dc0ed..4dc6880b4 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -564,8 +564,8 @@ W: $list num => $smsg->{num}, mid => $smsg->{mid}, }, 'PublicInbox::Smsg'; - my $v2w = { autime => $smsg->{ds}, cotime => $smsg->{ts} }; - $new_smsg->populate($new_mime, $v2w); + my $sync = { autime => $smsg->{ds}, cotime => $smsg->{ts} }; + $new_smsg->populate($new_mime, $sync); do_idx($self, \$raw, $new_mime, $new_smsg); } $rewritten->{rewrites}; @@ -950,7 +950,7 @@ sub reindex_oid ($$$$) { blob => $oid, mid => $mid0, }, 'PublicInbox::Smsg'; - $smsg->populate($mime, $self); + $smsg->populate($mime, $sync); if (do_idx($self, $msgref, $mime, $smsg)) { reindex_checkpoint($self, $sync, $git); } @@ -1225,14 +1225,14 @@ sub index_epoch ($$$) { while (my ($f, $at, $ct, $oid) = $stk->pop_rec) { $self->{current_info} = "$i.git $oid"; if ($f eq 'm') { - $self->{autime} = $at; - $self->{cotime} = $ct; + $sync->{autime} = $at; + $sync->{cotime} = $ct; reindex_oid($self, $sync, $git, $oid); } elsif ($f eq 'd') { unindex_oid($self, $git, $oid); } } - delete @$self{qw(autime cotime)}; + delete @$sync{qw(autime cotime)}; update_last_commit($self, $git, $i, $stk->{latest_cmt}); }