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 3A5031FBD1 for ; Mon, 1 Jun 2020 10:06:59 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 10/13] smsg: get rid of remaining {mime} users Date: Mon, 1 Jun 2020 10:06:54 +0000 Message-Id: <20200601100657.14700-11-e@yhbt.net> In-Reply-To: <20200601100657.14700-1-e@yhbt.net> References: <20200601100657.14700-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We'll let $smsg->populate take care of everything all at once without hanging onto the header object for too long. --- lib/PublicInbox/OverIdx.pm | 1 - lib/PublicInbox/Smsg.pm | 33 +++------------------------------ 2 files changed, 3 insertions(+), 31 deletions(-) diff --git a/lib/PublicInbox/OverIdx.pm b/lib/PublicInbox/OverIdx.pm index cb15baadf2b..a078f80451f 100644 --- a/lib/PublicInbox/OverIdx.pm +++ b/lib/PublicInbox/OverIdx.pm @@ -254,7 +254,6 @@ sub subject_path ($) { sub add_overview { my ($self, $mime, $smsg) = @_; $smsg->{lines} = $mime->body_raw =~ tr!\n!\n!; - $smsg->{mime} = $mime; # XXX temporary? my $hdr = $mime->header_obj; my $mids = mids_for_index($hdr); my $refs = parse_references($smsg, $hdr, $mids); diff --git a/lib/PublicInbox/Smsg.pm b/lib/PublicInbox/Smsg.pm index 9688c5592a2..9e363a112c0 100644 --- a/lib/PublicInbox/Smsg.pm +++ b/lib/PublicInbox/Smsg.pm @@ -12,7 +12,7 @@ use strict; use warnings; use base qw(Exporter); our @EXPORT_OK = qw(subject_normalized); -use PublicInbox::MID qw(mid_mime mids); +use PublicInbox::MID qw(mids); use PublicInbox::Address; use PublicInbox::MsgTime qw(msg_timestamp msg_datestamp); use Time::Local qw(timegm); @@ -96,13 +96,7 @@ sub lines ($) { $_[0]->{lines} } sub __hdr ($$) { my ($self, $field) = @_; - $self->{lc($field)} //= do { - my $mime = $self->{mime} or return; - my $val = join(', ', $mime->header($field)); - $val =~ tr/\r//d; - $val =~ tr/\t\n/ /; - $val; - }; + $self->{lc($field)}; } # for Import and v1 non-SQLite WWW code paths @@ -174,34 +168,13 @@ sub from_name { $self->{from_name}; } -sub ts { - my ($self) = @_; - $self->{ts} ||= eval { msg_timestamp($self->{mime}->header_obj) } || 0; -} - -sub ds { - my ($self) = @_; - $self->{ds} ||= eval { msg_datestamp($self->{mime}->header_obj); } || 0; -} - sub references { my ($self) = @_; my $x = $self->{references}; defined $x ? $x : ''; } -sub mid ($;$) { - my ($self, $mid) = @_; - - if (defined $mid) { - $self->{mid} = $mid; - } elsif (defined(my $rv = $self->{mid})) { - $rv; - } else { - die "NO {mime} for mid\n" unless $self->{mime}; - mid_mime($self->{mime}) # v1 w/o Xapian - } -} +sub mid { $_[0]->{mid} } our $REPLY_RE = qr/^re:\s+/i;