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 917BF1FD45 for ; Thu, 23 Jan 2020 23:06:00 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/6] mid: shorten uniq_mids logic Date: Thu, 23 Jan 2020 23:05:57 +0000 Message-Id: <20200123230559.16781-5-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: We won't be able to use List::Util::uniq here, but we can still shorten our logic and make it more consistent with the rest of our code which does similar things. --- lib/PublicInbox/MID.pm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/PublicInbox/MID.pm b/lib/PublicInbox/MID.pm index d7a42c38..33d5af74 100644 --- a/lib/PublicInbox/MID.pm +++ b/lib/PublicInbox/MID.pm @@ -120,9 +120,7 @@ sub uniq_mids ($;$) { warn "Message-ID: <$mid> too long, truncating\n"; $mid = substr($mid, 0, MAX_MID_SIZE); } - next if $seen->{$mid}; - push @ret, $mid; - $seen->{$mid} = 1; + push(@ret, $mid) unless $seen->{$mid}++; } \@ret; }