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 D7BC01FA0A for ; Mon, 1 Jun 2020 10:06:57 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 02/13] wwwatomstream: convert callers to use smsg_eml Date: Mon, 1 Jun 2020 10:06:46 +0000 Message-Id: <20200601100657.14700-3-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 can simplify WwwAtomStream callbacks by performing ->smsg_eml calls in the `feed_entry' sub itself. This simplifies callers, by reducing the number of places which can load an Eml object into memory. --- lib/PublicInbox/Feed.pm | 2 +- lib/PublicInbox/SearchView.pm | 2 +- lib/PublicInbox/WwwAtomStream.pm | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm index e64628be830..b770a35077c 100644 --- a/lib/PublicInbox/Feed.pm +++ b/lib/PublicInbox/Feed.pm @@ -12,7 +12,7 @@ use PublicInbox::Smsg; # this loads w/o Search::Xapian sub generate_i { my ($ctx) = @_; while (my $smsg = shift @{$ctx->{msgs}}) { - $ctx->{-inbox}->smsg_mime($smsg) and return $smsg; + return $smsg; } } diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm index 4336e4d9b2d..249cf53926d 100644 --- a/lib/PublicInbox/SearchView.pm +++ b/lib/PublicInbox/SearchView.pm @@ -340,7 +340,7 @@ sub adump_i { my $smsg = eval { PublicInbox::Smsg::from_mitem($mi, $ctx->{srch}); } or next; - $ctx->{-inbox}->smsg_mime($smsg) and return $smsg; + return $smsg; } } diff --git a/lib/PublicInbox/WwwAtomStream.pm b/lib/PublicInbox/WwwAtomStream.pm index c3fbb1a7cef..6ed0cb212d6 100644 --- a/lib/PublicInbox/WwwAtomStream.pm +++ b/lib/PublicInbox/WwwAtomStream.pm @@ -12,6 +12,7 @@ use warnings; use POSIX qw(strftime); use Digest::SHA qw(sha1_hex); use PublicInbox::Address; +use PublicInbox::MID qw(mids); use PublicInbox::Hval qw(ascii_html mid_href); use PublicInbox::MsgTime qw(msg_timestamp); @@ -99,9 +100,9 @@ sub atom_header { sub feed_entry { my ($self, $smsg) = @_; my $ctx = $self->{ctx}; - my $mid = $smsg->mid; # may extract Message-ID from {mime} - my $mime = delete $smsg->{mime}; - my $hdr = $mime->header_obj; + my $eml = $ctx->{-inbox}->smsg_eml($smsg) or return ''; + my $hdr = $eml->header_obj; + my $mid = $smsg->{mid} // mids($hdr)->[0]; my $irt = PublicInbox::View::in_reply_to($hdr); my $uuid = to_uuid($mid); my $base = $ctx->{feed_base_url}; @@ -141,7 +142,7 @@ sub feed_entry { qq(); $ctx->{obuf} = \$s; $ctx->{mhref} = $href; - PublicInbox::View::multipart_text_as_html($mime, $ctx); + PublicInbox::View::multipart_text_as_html($eml, $ctx); delete $ctx->{obuf}; $s .= ''; }