diff options
author | Ilya Zakharevich <ilya@math.berkeley.edu> | 1998-06-20 17:45:03 -0400 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-06-22 01:42:21 +0000 |
commit | a29cdaf07aa5601e42ae4955cc0f168e91a7c385 (patch) | |
tree | df8f6843ff7b401003b9005764037e304c51b815 | |
parent | a2008d6d9087873a23da5012f181cb674dbf4ab1 (diff) | |
download | perl-a29cdaf07aa5601e42ae4955cc0f168e91a7c385.tar.gz |
Avoid temporaries on recursion
Message-Id: <199806210145.VAA21629@monk.mps.ohio-state.edu>
p4raw-id: //depot/perl@1187
-rw-r--r-- | pp_ctl.c | 20 | ||||
-rw-r--r-- | pp_hot.c | 16 |
2 files changed, 29 insertions, 7 deletions
@@ -1486,10 +1486,22 @@ PP(pp_return) TAINT_NOT; if (gimme == G_SCALAR) { - if (MARK < SP) - *++newsp = (popsub2 && SvTEMP(*SP)) - ? *SP : sv_mortalcopy(*SP); - else + if (MARK < SP) { + if (popsub2) { + if (cxsub.cv && CvDEPTH(cxsub.cv) > 1) { + if (SvTEMP(TOPs)) { + *++newsp = SvREFCNT_inc(*SP); + FREETMPS; + sv_2mortal(*newsp); + } else { + FREETMPS; + *++newsp = sv_mortalcopy(*SP); + } + } else + *++newsp = (SvTEMP(*SP)) ? *SP : sv_mortalcopy(*SP); + } else + *++newsp = sv_mortalcopy(*SP); + } else *++newsp = &sv_undef; } else if (gimme == G_ARRAY) { @@ -1778,9 +1778,19 @@ PP(pp_leavesub) TAINT_NOT; if (gimme == G_SCALAR) { MARK = newsp + 1; - if (MARK <= SP) - *MARK = SvTEMP(TOPs) ? TOPs : sv_mortalcopy(TOPs); - else { + if (MARK <= SP) { + if (cxsub.cv && CvDEPTH(cxsub.cv) > 1) { + if (SvTEMP(TOPs)) { + *MARK = SvREFCNT_inc(TOPs); + FREETMPS; + sv_2mortal(*MARK); + } else { + FREETMPS; + *MARK = sv_mortalcopy(TOPs); + } + } else + *MARK = SvTEMP(TOPs) ? TOPs : sv_mortalcopy(TOPs); + } else { MEXTEND(MARK, 0); *MARK = &sv_undef; } |