From dd986388c89a46417c7513478adcf1da1d4b92ae Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 9 Jun 2023 10:31:08 +0000 Subject: add compat package for List::Util::uniqstr This will make it easier to switch in the far future while making callers easier-to-read (and more callers will be added). Anyways, Perl 5.26 is a long time away for enterprise users; but isolating compatibility code away can improve readability of code we actually care about in the meantime. --- lib/PublicInbox/Inbox.pm | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'lib/PublicInbox/Inbox.pm') diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index cb98d2ad..9afbb478 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -10,6 +10,7 @@ use PublicInbox::MID qw(mid2path); use PublicInbox::Eml; use List::Util qw(max); use Carp qw(croak); +use PublicInbox::Compat qw(uniqstr); # returns true if further checking is required sub check_inodes ($) { @@ -250,11 +251,7 @@ EOM # nntp://news.example.com/alt.example push @m, $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 = uniqstr @urls, @m; } \@urls; } @@ -274,8 +271,7 @@ sub pop3_url { @urls = map { m!\Apop3?s?://! ? $_ : "pop3://$_" } @$ps; if (my $mi = $self->{'pop3mirror'}) { my @m = map { m!\Apop3?s?://! ? $_ : "pop3://$_" } @$mi; - my %seen; # List::Util::uniq requires Perl 5.26+ - @urls = grep { !$seen{$_}++ } (@urls, @m); + @urls = uniqstr @urls, @m; } my $n = 0; for (@urls) { $n += s!/+\z!! } -- cgit v1.2.3-24-ge0c7