From ff2db829115a5db9cc4d046b4a9018cfba4ca6c0 Mon Sep 17 00:00:00 2001
From: Eric Wong <e@yhbt.net>
Date: Thu, 23 Jan 2020 23:05:56 +0000
Subject: [PATCH] inbox: simplify filtering for duplicate NNTP URLs

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;
 	};
-- 
2.51.0