about summary refs log tree commit homepage
path: root/lib/PublicInbox/ContentHash.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-08-01 08:12:27 +0000
committerEric Wong <e@yhbt.net>2020-08-02 08:26:20 +0000
commit77eafbd653d2efac546f2c330d8cf5e84bef2712 (patch)
treef33da0a4570d14882262ea4ee60ad7982afe6b8a /lib/PublicInbox/ContentHash.pm
parentfb4bfa102bfa702f13948ac689e54bac9d0084e0 (diff)
downloadpublic-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/ContentHash.pm')
-rw-r--r--lib/PublicInbox/ContentHash.pm15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/PublicInbox/ContentHash.pm b/lib/PublicInbox/ContentHash.pm
index 420dc5e7..1fe22955 100644
--- a/lib/PublicInbox/ContentHash.pm
+++ b/lib/PublicInbox/ContentHash.pm
@@ -53,29 +53,28 @@ sub content_dig_i {
 }
 
 sub content_digest ($) {
-        my ($mime) = @_;
+        my ($eml) = @_;
         my $dig = Digest::SHA->new(256);
-        my $hdr = $mime->header_obj;
 
         # References: and In-Reply-To: get used interchangeably
         # in some "duplicates" in LKML.  We treat them the same
         # in SearchIdx, so treat them the same for this:
         # do NOT consider the Message-ID as part of the content_hash
         # if we got here, we've already got Message-ID reuse
-        my %seen = map { $_ => 1 } @{mids($hdr)};
-        foreach my $mid (@{references($hdr)}) {
+        my %seen = map { $_ => 1 } @{mids($eml)};
+        foreach my $mid (@{references($eml)}) {
                 $dig->add("ref\0$mid\0") unless $seen{$mid}++;
         }
 
         # Only use Sender: if From is not present
         foreach my $h (qw(From Sender)) {
-                my @v = $hdr->header($h);
+                my @v = $eml->header($h);
                 if (@v) {
                         digest_addr($dig, $h, $_) foreach @v;
                 }
         }
         foreach my $h (qw(Subject Date)) {
-                my @v = $hdr->header($h);
+                my @v = $eml->header($h);
                 foreach my $v (@v) {
                         utf8::encode($v);
                         $dig->add("$h\0$v\0");
@@ -85,10 +84,10 @@ sub content_digest ($) {
         # not in the original message.  For the purposes of deduplication,
         # do not take it into account:
         foreach my $h (qw(To Cc)) {
-                my @v = $hdr->header($h);
+                my @v = $eml->header($h);
                 digest_addr($dig, $h, $_) foreach @v;
         }
-        msg_iter($mime, \&content_dig_i, $dig);
+        msg_iter($eml, \&content_dig_i, $dig);
         $dig;
 }