]> Sergey Matveev's repositories - public-inbox.git/commitdiff
overidx: parse_references: less error-prone args
authorEric Wong <e@yhbt.net>
Fri, 20 Mar 2020 08:18:17 +0000 (08:18 +0000)
committerEric Wong <e@yhbt.net>
Sun, 22 Mar 2020 09:00:23 +0000 (09:00 +0000)
Favor `$smsg->{mid}' instead of `$mid0' to reduce parameters
down-the-line, but favor passing the Email::MIME::Header object
around instead of relying on the bloat-prone `$smsg->{mime}'
and calling ->header_obj on it.

lib/PublicInbox/OverIdx.pm
lib/PublicInbox/SearchIdx.pm

index 9640f9d13bf57b1e9ae23d48bf9c7c41930b3b4b..f49dfa000431af739eb5e82060c5596fe1af5baf 100644 (file)
@@ -216,15 +216,13 @@ sub link_refs {
 }
 
 sub parse_references ($$$) {
 }
 
 sub parse_references ($$$) {
-       my ($smsg, $mid0, $mids) = @_;
-       my $mime = $smsg->{mime};
-       my $hdr = $mime->header_obj;
+       my ($smsg, $hdr, $mids) = @_;
        my $refs = references($hdr);
        push(@$refs, @$mids) if scalar(@$mids) > 1;
        return $refs if scalar(@$refs) == 0;
 
        # prevent circular references here:
        my $refs = references($hdr);
        push(@$refs, @$mids) if scalar(@$mids) > 1;
        return $refs if scalar(@$refs) == 0;
 
        # prevent circular references here:
-       my %seen = ( $mid0 => 1 );
+       my %seen = ( $smsg->{mid} => 1 );
        my @keep;
        foreach my $ref (@$refs) {
                if (length($ref) > PublicInbox::MID::MAX_MID_SIZE) {
        my @keep;
        foreach my $ref (@$refs) {
                if (length($ref) > PublicInbox::MID::MAX_MID_SIZE) {
@@ -258,7 +256,7 @@ sub add_overview {
        }, 'PublicInbox::Smsg';
        my $hdr = $mime->header_obj;
        my $mids = mids_for_index($hdr);
        }, 'PublicInbox::Smsg';
        my $hdr = $mime->header_obj;
        my $mids = mids_for_index($hdr);
-       my $refs = parse_references($smsg, $mid0, $mids);
+       my $refs = parse_references($smsg, $hdr, $mids);
        my $subj = $smsg->subject;
        my $xpath;
        if ($subj ne '') {
        my $subj = $smsg->subject;
        my $xpath;
        if ($subj ne '') {
index c0578809231800b3fb77e01556ecb1c20bd4b672..32be9c3ffbb63963f64c1958038f9b4c1d6899ba 100644 (file)
@@ -339,9 +339,9 @@ sub add_xapian ($$$$$$) {
                }
        }
        $smsg->{to} = $smsg->{cc} = '';
                }
        }
        $smsg->{to} = $smsg->{cc} = '';
-       PublicInbox::OverIdx::parse_references($smsg, $mid0, $mids);
        $smsg->{blob} = $oid;
        $smsg->{mid} = $mid0;
        $smsg->{blob} = $oid;
        $smsg->{mid} = $mid0;
+       PublicInbox::OverIdx::parse_references($smsg, $hdr, $mids);
        my $data = $smsg->to_doc_data;
        $doc->set_data($data);
        if (my $altid = $self->{-altid}) {
        my $data = $smsg->to_doc_data;
        $doc->set_data($data);
        if (my $altid = $self->{-altid}) {