diff options
author | Nicholas Clark <nick@ccl4.org> | 2007-03-17 13:01:18 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2007-03-17 13:01:18 +0000 |
commit | 5b6782b28b8a9d505447276bdd3de3a802f641dd (patch) | |
tree | fa4cae3fa81a8c9b194f402e4751ac0bfe3f5662 /op.c | |
parent | 22f5163f10c4a1f42ac0d46e22d5f1e42e085536 (diff) | |
download | perl-5b6782b28b8a9d505447276bdd3de3a802f641dd.tar.gz |
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
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 40 |
1 files changed, 13 insertions, 27 deletions
@@ -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; |