diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-06-22 18:59:02 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-06-23 06:04:01 -0700 |
commit | 943d76f23b94ab9adf16ba9537d0c969a62828c6 (patch) | |
tree | 71365db931b891ebeb7e0111376e802a878f3b5f | |
parent | 18beaace84297ebbc2de887d89c743e3502c0cd2 (diff) | |
download | perl-943d76f23b94ab9adf16ba9537d0c969a62828c6.tar.gz |
Make pp_leavesublv switch based on gimme
Put if(gimme == ...) on the outside and if(CxLVAL(cx)...) on the
inside. This reduces the amount of code, since the OPpENTERSUB_INARGS
case and the !CxLVAL case were both doing the same thing for scalars.
-rw-r--r-- | pp_ctl.c | 96 |
1 files changed, 45 insertions, 51 deletions
@@ -2436,33 +2436,9 @@ PP(pp_leavesublv) TAINT_NOT; - if (CxLVAL(cx) & OPpENTERSUB_INARGS) { - /* We are an argument to a function or grep(). - * This kind of lvalueness was legal before lvalue - * subroutines too, so be backward compatible: - * cannot report errors. */ - - /* Scalar context *is* possible, on the LHS of ->. */ - if (gimme == G_SCALAR) - goto rvalue; - if (gimme == G_ARRAY) { - mark = newsp + 1; - EXTEND_MORTAL(SP - newsp); - for (mark = newsp + 1; mark <= SP; mark++) { - if (SvTEMP(*mark)) - NOOP; - else if (SvFLAGS(*mark) & SVs_PADTMP) - *mark = sv_mortalcopy(*mark); - else { - /* Can be a localized value subject to deletion. */ - PL_tmps_stack[++PL_tmps_ix] = *mark; - SvREFCNT_inc_void(*mark); - } - } - } - } - else if (CxLVAL(cx)) { /* Leave it as it is if we can. */ - if (gimme == G_SCALAR) { + if (gimme == G_SCALAR) { + if (CxLVAL(cx) && !(CxLVAL(cx) & OPpENTERSUB_INARGS)) { + /* Leave it as it is if we can. */ MARK = newsp + 1; EXTEND_MORTAL(1); if (MARK == SP) { @@ -2505,7 +2481,47 @@ PP(pp_leavesublv) } SP = MARK; } - else if (gimme == G_ARRAY) { + else { + MARK = newsp + 1; + if (MARK <= SP) { + if (cx->blk_sub.cv && CvDEPTH(cx->blk_sub.cv) > 1) { + *MARK = SvREFCNT_inc(TOPs); + FREETMPS; + sv_2mortal(*MARK); + } + else + *MARK = SvTEMP(TOPs) + ? TOPs + : sv_2mortal(SvREFCNT_inc_simple_NN(TOPs)); + } + else { + MEXTEND(MARK, 0); + *MARK = &PL_sv_undef; + } + SP = MARK; + } + } + else if (gimme == G_ARRAY) { + if (CxLVAL(cx) & OPpENTERSUB_INARGS) { + /* We are an argument to a function or grep(). + * This kind of lvalueness was legal before lvalue + * subroutines too, so be backward compatible: + * cannot report errors. */ + mark = newsp + 1; + EXTEND_MORTAL(SP - newsp); + for (mark = newsp + 1; mark <= SP; mark++) { + if (SvTEMP(*mark)) + NOOP; + else if (SvFLAGS(*mark) & SVs_PADTMP) + *mark = sv_mortalcopy(*mark); + else { + /* Can be a localized value subject to deletion. */ + PL_tmps_stack[++PL_tmps_ix] = *mark; + SvREFCNT_inc_void(*mark); + } + } + } + else if (CxLVAL(cx)) { /* Leave it as it is if we can. */ EXTEND_MORTAL(SP - newsp); for (mark = newsp + 1; mark <= SP; mark++) { if (*mark != &PL_sv_undef @@ -2531,29 +2547,7 @@ PP(pp_leavesublv) } } } - } - else { - if (gimme == G_SCALAR) { - rvalue: - MARK = newsp + 1; - if (MARK <= SP) { - if (cx->blk_sub.cv && CvDEPTH(cx->blk_sub.cv) > 1) { - *MARK = SvREFCNT_inc(TOPs); - FREETMPS; - sv_2mortal(*MARK); - } - else - *MARK = SvTEMP(TOPs) - ? TOPs - : sv_2mortal(SvREFCNT_inc_simple_NN(TOPs)); - } - else { - MEXTEND(MARK, 0); - *MARK = &PL_sv_undef; - } - SP = MARK; - } - else if (gimme == G_ARRAY) { + else { for (MARK = newsp + 1; MARK <= SP; MARK++) { if (!SvTEMP(*MARK)) *MARK = sv_2mortal(SvREFCNT_inc_simple_NN(*MARK)); |