summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2015-08-27 14:45:13 +0100
committerDavid Mitchell <davem@iabyn.com>2016-02-03 08:59:39 +0000
commit4ad63d708f405909d048160f3eaf32590132e3cb (patch)
tree04f12bbfdcae313165344a33122e1bf142a74bdb /pp_ctl.c
parent88dc09d3822433b175dd40870d0509ff9b2ce901 (diff)
downloadperl-4ad63d708f405909d048160f3eaf32590132e3cb.tar.gz
pp_enteriter: tidy itervar-setting code
rename itervar to itervarp since it's more like an SV** than an SV*, and set itersave earlier so that it can be used directly rather than repeatedly dereffing itervarp. Shouldn't be any functional change.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index ce5861b237..89aaf3a884 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2117,7 +2117,7 @@ PP(pp_enteriter)
dSP; dMARK;
PERL_CONTEXT *cx;
const I32 gimme = GIMME_V;
- void *itervar; /* location of the iteration variable */
+ void *itervarp; /* GV or pad slot of the iteration variable */
SV *itersave; /* the old var in the iterator var slot */
U8 cxtype = CXt_LOOP_FOR;
@@ -2125,29 +2125,30 @@ PP(pp_enteriter)
SAVETMPS;
if (PL_op->op_targ) { /* "my" variable */
- itervar = &PAD_SVl(PL_op->op_targ);
+ itervarp = &PAD_SVl(PL_op->op_targ);
+ itersave = *(SV**)itervarp;
+ assert(itersave);
if (PL_op->op_private & OPpLVAL_INTRO) { /* for my $x (...) */
/* the SV currently in the pad slot is never live during
* iteration (the slot is always aliased to one of the items)
* so it's always stale */
- SvPADSTALE_on(*(SV**)itervar);
+ SvPADSTALE_on(itersave);
}
- itersave = SvREFCNT_inc(*(SV**)itervar);
- assert(itersave);
+ SvREFCNT_inc_simple_void_NN(itersave);
}
else if (LIKELY(isGV(TOPs))) { /* symbol table variable */
GV * const gv = MUTABLE_GV(POPs);
SV** svp = &GvSV(gv);
+ itervarp = (void *)gv;
itersave = *svp;
*svp = newSV(0);
- itervar = (void *)gv;
}
else {
SV * const sv = POPs;
assert(SvTYPE(sv) == SVt_PVMG);
assert(SvMAGIC(sv));
assert(SvMAGIC(sv)->mg_type == PERL_MAGIC_lvref);
- itervar = (void *)sv;
+ itervarp = (void *)sv;
cxtype |= CXp_FOR_LVREF;
itersave = NULL;
}
@@ -2158,7 +2159,7 @@ PP(pp_enteriter)
ENTER_with_name("loop2");
PUSHBLOCK(cx, cxtype, SP);
- PUSHLOOP_FOR(cx, itervar, itersave, MARK);
+ PUSHLOOP_FOR(cx, itervarp, itersave, MARK);
if (PL_op->op_flags & OPf_STACKED) {
SV *maybe_ary = POPs;
if (SvTYPE(maybe_ary) != SVt_PVAV) {