From e5ce4d8a834b79cee1a08780a9440df2a1c47b86 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Wed, 26 Aug 2015 09:53:09 +0100 Subject: [PATCH] S_leave_common(): simplify SVs_PADTMP handling Now that SVs_PADTMP is a simple flag again (at one point its meaning was inferred from the state of two flags) it no longer needs special handling in S_leave_common(). --- pp_ctl.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/pp_ctl.c b/pp_ctl.c index 6e4173b..d3c35c8 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -1993,11 +1993,12 @@ PP(pp_dbstate) } /* S_leave_common: Common code that many functions in this file use on - scope exit. */ + scope exit. -/* SVs on the stack that have any of the flags passed in are left as is. - Other SVs are protected via the mortals stack if lvalue is true, and - copied otherwise. + Process the return args on the stack in the range (mark..sp) based on + context, with any final args starting at newsp. + Args are mortal copied (or mortalied if lvalue) unless its safe to use + as-is, based on whether it the specified flags Also, taintedness is cleared. */ @@ -2006,17 +2007,12 @@ STATIC SV ** S_leave_common(pTHX_ SV **newsp, SV **sp, SV **mark, I32 gimme, U32 flags, bool lvalue) { - bool padtmp = 0; PERL_ARGS_ASSERT_LEAVE_COMMON; TAINT_NOT; - if (flags & SVs_PADTMP) { - flags &= ~SVs_PADTMP; - padtmp = 1; - } if (gimme == G_SCALAR) { if (MARK < SP) - *++newsp = ((SvFLAGS(*SP) & flags) || (padtmp && SvPADTMP(*SP))) + *++newsp = (SvFLAGS(*SP) & flags) ? *SP : lvalue ? sv_2mortal(SvREFCNT_inc_simple_NN(*SP)) @@ -2032,7 +2028,7 @@ S_leave_common(pTHX_ SV **newsp, SV **sp, SV **mark, I32 gimme, else if (gimme == G_ARRAY) { /* in case LEAVE wipes old return values */ while (++MARK <= SP) { - if ((SvFLAGS(*MARK) & flags) || (padtmp && SvPADTMP(*MARK))) + if (SvFLAGS(*MARK) & flags) *++newsp = *MARK; else { *++newsp = lvalue -- 1.8.3.1