diff options
author | David Mitchell <davem@iabyn.com> | 2015-05-24 16:53:05 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2015-06-19 08:44:17 +0100 |
commit | a8fc6464d21b7e1fc056ca7bd504ada3f88770d7 (patch) | |
tree | a8d9718ffcf95b226256719a41e55b34e5031dfe | |
parent | 716436dc7bfe93c174394b2d148df54b22c6f1fb (diff) | |
download | perl-a8fc6464d21b7e1fc056ca7bd504ada3f88770d7.tar.gz |
S_return_lvalues(): merge two similar blocks
Two blocks of error-reporting code both clean up the context state and
then croak with a similar message. Make the second block just goto the
first block instead.
-rw-r--r-- | pp_ctl.c | 18 |
1 files changed, 5 insertions, 13 deletions
@@ -2296,6 +2296,7 @@ S_return_lvalues(pTHX_ SV **base) PERL_CONTEXT *cx; SV *sv; bool ref; + const char *what = NULL; POPBLOCK(cx,newpm); cxstack_ix++; /* preserve cx entry on stack for use by POPSUB */ @@ -2307,7 +2308,6 @@ S_return_lvalues(pTHX_ SV **base) if (gimme == G_SCALAR) { if (CxLVAL(cx) && !ref) { /* Leave it as it is if we can. */ SV *sv; - const char *what = NULL; if (MARK < SP) { assert(MARK+1 == SP); if ((SvPADTMP(TOPs) || SvREADONLY(TOPs)) && @@ -2322,6 +2322,7 @@ S_return_lvalues(pTHX_ SV **base) /* sub:lvalue{} will take us here. */ what = "undef"; } + croak: LEAVE; POPSUB(cx,sv); cxstack_ix--; @@ -2380,19 +2381,10 @@ S_return_lvalues(pTHX_ SV **base) if (*MARK != &PL_sv_undef && (SvPADTMP(*MARK) || SvREADONLY(*MARK)) ) { - const bool ro = cBOOL( SvREADONLY(*MARK) ); - SV *sv; /* Might be flattened array after $#array = */ - PUTBACK; - LEAVE; - POPSUB(cx,sv); - cxstack_ix--; - PL_curpm = newpm; - LEAVESUB(sv); - /* diag_listed_as: Can't return %s from lvalue subroutine */ - Perl_croak(aTHX_ - "Can't return a %s from lvalue subroutine", - ro ? "readonly value" : "temporary"); + what = SvREADONLY(*MARK) + ? "a readonly value" : "a temporary"; + goto croak; } else *++newsp = |