]> Sergey Matveev's repositories - public-inbox.git/commitdiff
mid: shorten uniq_mids logic
authorEric Wong <e@yhbt.net>
Thu, 23 Jan 2020 23:05:57 +0000 (23:05 +0000)
committerEric Wong <e@yhbt.net>
Fri, 24 Jan 2020 23:04:55 +0000 (23:04 +0000)
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

index d7a42c38573b17111458ddccd32e821355f79b91..33d5af7450a2610702591c7ad864cb81e981084c 100644 (file)
@@ -120,9 +120,7 @@ sub uniq_mids ($;$) {
                        warn "Message-ID: <$mid> too long, truncating\n";
                        $mid = substr($mid, 0, MAX_MID_SIZE);
                }
                        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;
 }
        }
        \@ret;
 }