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 B88AA1FD50 for ; Thu, 23 Jan 2020 23:06:00 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 5/6] wwwstream: shorten cloneurl uniquification Date: Thu, 23 Jan 2020 23:05:58 +0000 Message-Id: <20200123230559.16781-6-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: Another place where List::Scalar::uniq doesn't make sense, but there's a small op reduction to be had anyways. --- lib/PublicInbox/WwwStream.pm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm index 8f5a6526..a724d069 100644 --- a/lib/PublicInbox/WwwStream.pm +++ b/lib/PublicInbox/WwwStream.pm @@ -89,12 +89,12 @@ sub _html_end { my $ibx = $ctx->{-inbox}; my $desc = ascii_html($ibx->description); - my (%seen, @urls); + my @urls; my $http = $self->{base_url}; my $max = $ibx->max_git_epoch; my $dir = (split(m!/!, $http))[-1]; + my %seen = ($http => 1); if (defined($max)) { # v2 - $seen{$http} = 1; for my $i (0..$max) { # old parts my be deleted: -d "$ibx->{inboxdir}/git/$i.git" or next; @@ -103,15 +103,13 @@ sub _html_end { push @urls, "$url $dir/git/$i.git"; } } else { # v1 - $seen{$http} = 1; push @urls, $http; } # FIXME: epoch splits can be different in other repositories, # use the "cloneurl" file as-is for now: foreach my $u (@{$ibx->cloneurl}) { - next if $seen{$u}; - $seen{$u} = 1; + next if $seen{$u}++; push @urls, $u =~ /\Ahttps?:/ ? qq($u) : $u; }