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-ASN: 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 4C06F1F5A1 for ; Thu, 23 Jan 2020 23:06:00 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/6] nntp: simplify setting X-Alt-Message-ID Date: Thu, 23 Jan 2020 23:05:55 +0000 Message-Id: <20200123230559.16781-3-e@yhbt.net> In-Reply-To: <20200123230559.16781-1-e@yhbt.net> References: <20200123230559.16781-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We can cut down on the number of operations required using "grep" instead of "foreach". --- lib/PublicInbox/NNTP.pm | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm index 35729f00..12f74c3d 100644 --- a/lib/PublicInbox/NNTP.pm +++ b/lib/PublicInbox/NNTP.pm @@ -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); }