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 6E52D1F885 for ; Thu, 23 Jan 2020 23:06:00 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 3/6] inbox: simplify filtering for duplicate NNTP URLs Date: Thu, 23 Jan 2020 23:05:56 +0000 Message-Id: <20200123230559.16781-4-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: And add a note to remind ourselves to use List::Util::uniq when it becomes common. --- lib/PublicInbox/Inbox.pm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index e834d565..07e8b5b7 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -293,12 +293,11 @@ sub nntp_url { # nntp://news.example.com/alt.example push @m, $u; } - my %seen = map { $_ => 1 } @urls; - foreach my $u (@m) { - next if $seen{$u}; - $seen{$u} = 1; - push @urls, $u; - } + + # List::Util::uniq requires Perl 5.26+, maybe we + # can use it by 2030 or so + my %seen; + @urls = grep { !$seen{$_}++ } (@urls, @m); } \@urls; };