]> Sergey Matveev's repositories - public-inbox.git/commitdiff
nntp: simplify setting X-Alt-Message-ID
authorEric Wong <e@yhbt.net>
Thu, 23 Jan 2020 23:05:55 +0000 (23:05 +0000)
committerEric Wong <e@yhbt.net>
Fri, 24 Jan 2020 23:04:52 +0000 (23:04 +0000)
We can cut down on the number of operations required
using "grep" instead of "foreach".

lib/PublicInbox/NNTP.pm

index 35729f003daecc99b12826df25456815b21f0c2e..12f74c3dd3fb24955aeec4bb16f70418615e4ebd 100644 (file)
@@ -423,10 +423,7 @@ sub set_nntp_headers ($$$$$) {
                $hdr->header_set('Message-ID', $mid0);
                my @alt = $hdr->header('X-Alt-Message-ID');
                my %seen = map { $_ => 1 } (@alt, $mid0);
-               foreach my $m (@mids) {
-                       next if $seen{$m}++;
-                       push @alt, $m;
-               }
+               push(@alt, grep { !$seen{$_}++ } @mids);
                $hdr->header_set('X-Alt-Message-ID', @alt);
        }