From: Nicholas Clark Date: Sat, 17 Mar 2007 13:01:18 +0000 (+0000) Subject: The code in newCONDOP can be made visibly simpler by using intermediate X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5b6782b28b8a9d505447276bdd3de3a802f641dd;p=p5sagit%2Fp5-mst-13.2.git The code in newCONDOP can be made visibly simpler by using intermediate variables. It's also 8 bytes smaller with -Os p4raw-id: //depot/perl@30606 --- diff --git a/op.c b/op.c index 981b765..e6aadae 100644 --- a/op.c +++ b/op.c @@ -4236,38 +4236,24 @@ Perl_newCONDOP(pTHX_ I32 flags, OP *first, OP *trueop, OP *falseop) scalarboolean(first); if (first->op_type == OP_CONST) { + /* Left or right arm of the conditional? */ + const bool left = SvTRUE(((SVOP*)first)->op_sv); + OP *live = left ? trueop : falseop; + OP *const dead = left ? falseop : trueop; if (first->op_private & OPpCONST_BARE && first->op_private & OPpCONST_STRICT) { no_bareword_allowed(first); } - if (SvTRUE(((SVOP*)first)->op_sv)) { -#ifdef PERL_MAD - if (PL_madskills) { - trueop = newUNOP(OP_NULL, 0, trueop); - op_getmad(first,trueop,'C'); - op_getmad(falseop,trueop,'e'); - } else -#endif - { - op_free(first); - op_free(falseop); - } - return trueop; - } - else { -#ifdef PERL_MAD - if (PL_madskills) { - falseop = newUNOP(OP_NULL, 0, falseop); - op_getmad(first,falseop,'C'); - op_getmad(trueop,falseop,'t'); - } else -#endif - { - op_free(first); - op_free(trueop); - } - return falseop; + if (PL_madskills) { + /* This is all dead code when PERL_MAD is not defined. */ + live = newUNOP(OP_NULL, 0, live); + op_getmad(first, live, 'C'); + op_getmad(dead, live, left ? 'e' : 't'); + } else { + op_free(first); + op_free(dead); } + return live; } NewOp(1101, logop, 1, LOGOP); logop->op_type = OP_COND_EXPR;