]> Sergey Matveev's repositories - public-inbox.git/commitdiff
mid: use defined-or with `push' for uniqueness check
authorEric Wong <e@80x24.org>
Thu, 31 Dec 2020 13:51:36 +0000 (13:51 +0000)
committerEric Wong <e@80x24.org>
Fri, 1 Jan 2021 05:00:39 +0000 (05:00 +0000)
As shown recently in commit a05445fb400108e60ede7d377cf3b26a0392eb24
("config: config_fh_parse: micro-optimize"), the relying on
the return value of `push' and defined-or operators can avoid
modifying a the hash value scalar with an increment.

lib/PublicInbox/MID.pm

index 5aeffb8c675bb2882a1f50b92505206e386191e9..601f4c9b125847f478952a0fdf7764b97e9d8ff3 100644 (file)
@@ -119,7 +119,7 @@ sub uniq_mids ($;$) {
                        warn "Message-ID: <$mid> too long, truncating\n";
                        $mid = substr($mid, 0, MAX_MID_SIZE);
                }
-               push(@ret, $mid) unless $seen->{$mid}++;
+               $seen->{$mid} //= push(@ret, $mid);
        }
        \@ret;
 }