diff options
author | Eric Wong <e@yhbt.net> | 2020-08-01 08:12:27 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-08-02 08:26:20 +0000 |
commit | 77eafbd653d2efac546f2c330d8cf5e84bef2712 (patch) | |
tree | f33da0a4570d14882262ea4ee60ad7982afe6b8a /lib/PublicInbox/Import.pm | |
parent | fb4bfa102bfa702f13948ac689e54bac9d0084e0 (diff) | |
download | public-inbox-77eafbd653d2efac546f2c330d8cf5e84bef2712.tar.gz |
remove unnecessary ->header_obj calls
We used ->header_obj in the past as an optimization with Email::MIME. That optimization is no longer necessary with PublicInbox::Eml. This doesn't make any functional difference even if we were to go back to Email::MIME. However, it reduces the amount of code we have and slightly reduces allocations with PublicInbox::Eml.
Diffstat (limited to 'lib/PublicInbox/Import.pm')
-rw-r--r-- | lib/PublicInbox/Import.pm | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm index 07a49518..700b4026 100644 --- a/lib/PublicInbox/Import.pm +++ b/lib/PublicInbox/Import.pm @@ -285,15 +285,14 @@ sub extract_cmt_info ($;$) { # $mime is PublicInbox::Eml, but remains Email::MIME-compatible $smsg //= bless {}, 'PublicInbox::Smsg'; - my $hdr = $mime->header_obj; - $smsg->populate($hdr); + $smsg->populate($mime); my $sender = ''; my $from = delete($smsg->{From}) // ''; my ($email) = PublicInbox::Address::emails($from); my ($name) = PublicInbox::Address::names($from); if (!defined($name) || !defined($email)) { - $sender = $hdr->header('Sender') // ''; + $sender = $mime->header('Sender') // ''; $name //= (PublicInbox::Address::names($sender))[0]; $email //= (PublicInbox::Address::emails($sender))[0]; } @@ -346,13 +345,12 @@ sub append_mid ($$) { } sub v1_mid0 ($) { - my ($mime) = @_; - my $hdr = $mime->header_obj; - my $mids = mids($hdr); + my ($eml) = @_; + my $mids = mids($eml); if (!scalar(@$mids)) { # spam often has no Message-ID - my $mid0 = digest2mid(content_digest($mime), $hdr); - append_mid($hdr, $mid0); + my $mid0 = digest2mid(content_digest($eml), $eml); + append_mid($eml, $mid0); return $mid0; } $mids->[0]; @@ -671,8 +669,7 @@ version 1.0 my $parsed = PublicInbox::Eml->new($message); my $ret = $im->add($parsed); if (!defined $ret) { - warn "duplicate: ", - $parsed->header_obj->header_raw('Message-ID'), "\n"; + warn "duplicate: ", $parsed->header_raw('Message-ID'), "\n"; } else { print "imported at mark $ret\n"; } |