about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-04-25 10:50:49 +0000
committerEric Wong <e@80x24.org>2023-04-25 20:51:31 +0000
commit8080f099f6a40ce9b79e62f8c424ece42fdffa7a (patch)
treeb247b2998475a52f721e1e27c78d3f06d7640b11 /lib
parent10f31b26e010243ab919dbafeb6f95c6e30640e9 (diff)
downloadpublic-inbox-8080f099f6a40ce9b79e62f8c424ece42fdffa7a.tar.gz
It's possible in theory that Perl could be smarter and free
memory a tad sooner this way.  Regardless, fewer lines of code
is easier-to-navigate/read and can save optree size and reduce
parsing times.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/ContentHash.pm6
-rw-r--r--lib/PublicInbox/MID.pm6
2 files changed, 4 insertions, 8 deletions
diff --git a/lib/PublicInbox/ContentHash.pm b/lib/PublicInbox/ContentHash.pm
index d3ff146a..a4f6196f 100644
--- a/lib/PublicInbox/ContentHash.pm
+++ b/lib/PublicInbox/ContentHash.pm
@@ -76,8 +76,7 @@ sub content_digest ($;$) {
                 last;
         }
         foreach my $h (qw(Subject Date)) {
-                my @v = $eml->header($h);
-                foreach my $v (@v) {
+                for my $v ($eml->header($h)) {
                         utf8::encode($v);
                         $dig->add("$h\0$v\0");
                 }
@@ -86,8 +85,7 @@ 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 = $eml->header($h);
-                digest_addr($dig, $h, $_) foreach @v;
+                digest_addr($dig, $h, $_) for ($eml->header($h));
         }
         msg_iter($eml, \&content_dig_i, $dig);
         $dig;
diff --git a/lib/PublicInbox/MID.pm b/lib/PublicInbox/MID.pm
index 4819cc25..b1ae9939 100644
--- a/lib/PublicInbox/MID.pm
+++ b/lib/PublicInbox/MID.pm
@@ -92,8 +92,7 @@ sub references ($) {
         my ($hdr) = @_;
         my @mids;
         foreach my $f (qw(References In-Reply-To)) {
-                my @v = $hdr->header_raw($f);
-                foreach my $v (@v) {
+                for my $v ($hdr->header_raw($f)) {
                         push(@mids, ($v =~ /$MID_EXTRACT/g));
                 }
         }
@@ -104,8 +103,7 @@ sub references ($) {
         my %addr = ( y => 1, n => 1 );
 
         foreach my $f (qw(To From Cc)) {
-                my @v = $hdr->header_raw($f);
-                foreach my $v (@v) {
+                for my $v ($hdr->header_raw($f)) {
                         $addr{$_} = 1 for (PublicInbox::Address::emails($v));
                 }
         }