I was not aware of List::MoreUtils::firstval. Okay, added it to the benchmark. It mostly has the same speed as List::Util::first, I wonder what the differences are.
% bencher -Ilib -m PERLANCAR/grep_bool --include-participant-pattern List:: +---------------------------+----------+-----------+-----------+------------+---------+---------+ | participant | dataset | rate (/s) | time (μs) | vs_slowest | errors | samples | +---------------------------+----------+-----------+-----------+------------+---------+---------+ | List::Util::first | notfound | 3900 | 250 | 1 | 1.8e-06 | 20 | | List::MoreUtils::firstval | last | 3980 | 251 | 1.01 | 5.3e-08 | 20 | | List::MoreUtils::firstval | notfound | 4000 | 250 | 1 | 1.1e-06 | 20 | | List::Util::first | last | 4100 | 240 | 1 | 4.8e-07 | 20 | | List::Util::first | first | 46400 | 21.6 | 11.8 | 2.1e-08 | 31 | | List::MoreUtils::firstval | first | 46406 | 21.549 | 11.788 | 1.5e-10 | 20 | +---------------------------+----------+-----------+-----------+------------+---------+---------+
In reply to Re^6: Shortcutting grep in boolean context
by perlancar
in thread Shortcutting grep in boolean context
by perlancar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |