fully short-circuit &&, ||, //
Currently in an expression like (A || B || C || D), if A is true, then
B, C and D aren't evaluated, but the 2nd, 3rd and 4th OR ops are *still*
executed. Use the peephole optimiser to bypass them.
i.e. change the op tree from
- A - OR - OR - OR - X---
\ / \ / \ /
B C D
to
- A - OR --------------------X---
\ /
B - OR -----------/
\ /
C - OR --/
\ /
D
With this, the following code's execution time reduces from 1.6s to 0.9s
approx on my system:
my $a = 1; my $b = 0; my $x = 0;
for (1..10_000_000) {
if ($a || $b || $b || $b || $b || $b) {
$x++;
}
}