@@ -3645,10 +3645,10 @@ Perl_rpeep(pTHX_ OP *o)
36453645 /* Is there an empty "else" block or ternary false branch?
36463646 If so, optimise away the OP_STUB if safe to do so. */
36473647 stub = o -> op_next ;
3648- if ((stub -> op_flags & OPf_WANT ) != OPf_WANT_SCALAR ) {
3648+ if ((stub == falseop ) && ( stub -> op_flags & OPf_WANT ) != OPf_WANT_SCALAR ) {
36493649 if (stub -> op_type == OP_STUB && !OpSIBLING (stub ) ){
36503650 OP * stubsib = OpSIBLING (stub );
3651- if (( stub == falseop ) && !stubsib ) {
3651+ if (!stubsib ) {
36523652 /* cond_expr
36533653 * -condition-
36543654 * - if -
@@ -3659,41 +3659,27 @@ Perl_rpeep(pTHX_ OP *o)
36593659 o -> op_next = stub -> op_next ;
36603660 op_sibling_splice (o , OpSIBLING (cLOGOP -> op_first ), 1 , NULL );
36613661 op_free (stub );
3662+ }
36623663 } else { /* Unexpected */ }
3663- } else if (OP_TYPE_IS (stub ,OP_ENTER ) &&
3664- OP_TYPE_IS (falseop , OP_LEAVE )) {
3665- OP * enter = stub ;
3666- OP * stub = OpSIBLING (enter );
3667- if (stub && OP_TYPE_IS (stub , OP_STUB ) ){
3668- assert (!(stub -> op_flags & OPf_KIDS ));
3669- OP * stubsib = OpSIBLING (stub );
3670- assert (stubsib );
3671- if (OP_TYPE_IS (stubsib , OP_NULL ) &&
3672- !OpSIBLING (stubsib ) &&
3673- !(stubsib -> op_flags & OPf_KIDS ) ) {
3674- /* cond_expr
3675- * -condition-
3676- * - if -
3677- * leave
3678- * enter
3679- * stub
3680- * null
3681- */
3682- /* Ignoring it for now, pending further exploration.*/
3683- /*
3684- o->op_flags |= OPf_SPECIAL; // For B::Deparse
3664+ } else if (OP_TYPE_IS (falseop ,OP_SCOPE ) &&
3665+ (falseop -> op_flags & OPf_KIDS )) {
3666+ OP * stub = cLISTOPx (falseop )-> op_first ;
3667+ if (OP_TYPE_IS_OR_WAS (stub , OP_STUB ) && !OpSIBLING (stub )) {
3668+ assert (!OpSIBLING (stub ));
3669+ assert (o -> op_next != falseop );
3670+ assert (!(stub -> op_flags & OPf_KIDS ));
3671+ o -> op_flags |= OPf_SPECIAL ; /* For B::Deparse */
3672+ op_sibling_splice (o , OpSIBLING (cLOGOP -> op_first ), 1 , NULL );
3673+ if (o -> op_next == stub ) {
3674+ if (stub -> op_next == falseop )
36853675 o -> op_next = falseop -> op_next ;
3686- op_sibling_splice(o, OpSIBLING(cLOGOP->op_first), 1, NULL);
3687- op_free(enter);
3688- op_free(stub);
3689- op_free(stubsib);
3690- op_free(falseop);
3691- */
3692- }
3676+ else
3677+ o -> op_next = stub -> op_next ;
36933678 }
3679+ // op_free(stub);
3680+ op_free (falseop );
36943681 }
36953682 }
3696-
36973683 }
36983684 /* FALLTHROUGH */
36993685 case OP_MAPWHILE :
0 commit comments