From: Eric Wong Date: Thu, 23 Jan 2020 23:05:56 +0000 (+0000) Subject: inbox: simplify filtering for duplicate NNTP URLs X-Git-Tag: v1.3.0~86 X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=commitdiff_plain;h=ff2db829115a5db9cc4d046b4a9018cfba4ca6c0 inbox: simplify filtering for duplicate NNTP URLs And add a note to remind ourselves to use List::Util::uniq when it becomes common. --- 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; };