Commit ef13941
committed
Perl_rpeep: Fix empty else {} optimization in OP_COND_EXPR case
Until `else` blocks were subject to the same block scoping rules as `if`
and `elsif`, an empty `else` block or ternary condition would arrive at
the peephole optimizer as a bare stub OP:
+--null (ex-stub) OP(0x562e555a7310)
FLAGS = (...,PARENS,SLABBED)
Now, it could arrive in that form OR as a SCOPE + NULL:
scope LISTOP(0x5603b282b190)
PARENT ===> 3 [cond_expr 0x5603b282b770]
FLAGS = (VOID,KIDS,SLABBED)
|
+--null (ex-stub) OP(0x5603b282b350) ===> 1 [scope 0x5603b282b190]
FLAGS = (VOID,SLABBED)
This commit updates the "empty else" optimization on `OP_COND_EXPR`s so
that the OPs associated with empty "else" conditions are removed (when
not in scalar context) regardless of which form they arrive in.1 parent 2f42d3c commit ef13941
2 files changed
+23
-32
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4552 | 4552 | | |
4553 | 4553 | | |
4554 | 4554 | | |
| 4555 | + | |
| 4556 | + | |
| 4557 | + | |
| 4558 | + | |
| 4559 | + | |
| 4560 | + | |
| 4561 | + | |
4555 | 4562 | | |
4556 | 4563 | | |
4557 | 4564 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3645 | 3645 | | |
3646 | 3646 | | |
3647 | 3647 | | |
3648 | | - | |
| 3648 | + | |
3649 | 3649 | | |
3650 | 3650 | | |
3651 | | - | |
| 3651 | + | |
3652 | 3652 | | |
3653 | 3653 | | |
3654 | 3654 | | |
| |||
3659 | 3659 | | |
3660 | 3660 | | |
3661 | 3661 | | |
| 3662 | + | |
3662 | 3663 | | |
3663 | | - | |
3664 | | - | |
3665 | | - | |
3666 | | - | |
3667 | | - | |
3668 | | - | |
3669 | | - | |
3670 | | - | |
3671 | | - | |
3672 | | - | |
3673 | | - | |
3674 | | - | |
3675 | | - | |
3676 | | - | |
3677 | | - | |
3678 | | - | |
3679 | | - | |
3680 | | - | |
3681 | | - | |
3682 | | - | |
3683 | | - | |
3684 | | - | |
| 3664 | + | |
| 3665 | + | |
| 3666 | + | |
| 3667 | + | |
| 3668 | + | |
| 3669 | + | |
| 3670 | + | |
| 3671 | + | |
| 3672 | + | |
| 3673 | + | |
3685 | 3674 | | |
3686 | | - | |
3687 | | - | |
3688 | | - | |
3689 | | - | |
3690 | | - | |
3691 | | - | |
3692 | | - | |
| 3675 | + | |
| 3676 | + | |
3693 | 3677 | | |
| 3678 | + | |
3694 | 3679 | | |
3695 | 3680 | | |
3696 | | - | |
3697 | 3681 | | |
3698 | 3682 | | |
3699 | 3683 | | |
| |||
0 commit comments