]> Sergey Matveev's repositories - public-inbox.git/commitdiff
inbox: simplify filtering for duplicate NNTP URLs
authorEric Wong <e@yhbt.net>
Thu, 23 Jan 2020 23:05:56 +0000 (23:05 +0000)
committerEric Wong <e@yhbt.net>
Fri, 24 Jan 2020 23:04:53 +0000 (23:04 +0000)
And add a note to remind ourselves to use List::Util::uniq
when it becomes common.

lib/PublicInbox/Inbox.pm

index e834d565da62915267898ce1dd7537dbabc390c3..07e8b5b754071de5c8264d9e95034469e45b1128 100644 (file)
@@ -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;
        };