summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2015-12-18 12:34:37 +0000
committerDavid Mitchell <davem@iabyn.com>2016-02-03 09:18:35 +0000
commit2c49879ec3c26fea291b0d87fd14cdea3709bcc9 (patch)
tree821e087dba6329206527940b05548adbcf7b3cfc /pp_ctl.c
parentabaf5d5ada4e3983478a6c89f54ed039ef236595 (diff)
downloadperl-2c49879ec3c26fea291b0d87fd14cdea3709bcc9.tar.gz
pp_enteriter: use efficient SvREFCNT_inc variant
replace a couple of SvREFCNT_inc() with SvREFCNT_inc_simple_void_NN(). Also add a couple of code comments.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index 1758448d0b..43dfe3c044 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2145,9 +2145,14 @@ PP(pp_enteriter)
PUSHBLOCK(cx, cxflags, MARK);
PUSHLOOP_FOR(cx, itervarp, itersave);
+
if (PL_op->op_flags & OPf_STACKED) {
+ /* OPf_STACKED implies either a single array: for(@), with a
+ * single AV on the stack, or a range: for (1..5), with 1 and 5 on
+ * the stack */
SV *maybe_ary = POPs;
if (SvTYPE(maybe_ary) != SVt_PVAV) {
+ /* range */
dPOPss;
SV * const right = maybe_ary;
if (UNLIKELY(cxflags & CXp_FOR_LVREF))
@@ -2166,7 +2171,7 @@ PP(pp_enteriter)
cx->cx_type |= CXt_LOOP_LAZYSV;
cx->blk_loop.state_u.lazysv.cur = newSVsv(sv);
cx->blk_loop.state_u.lazysv.end = right;
- SvREFCNT_inc(right);
+ SvREFCNT_inc_simple_void_NN(right);
(void) SvPV_force_nolen(cx->blk_loop.state_u.lazysv.cur);
/* This will do the upgrade to SVt_PV, and warn if the value
is uninitialised. */
@@ -2180,9 +2185,10 @@ PP(pp_enteriter)
}
}
else /* SvTYPE(maybe_ary) == SVt_PVAV */ {
+ /* for (@array) {} */
cx->cx_type |= CXt_LOOP_ARY;
cx->blk_loop.state_u.ary.ary = MUTABLE_AV(maybe_ary);
- SvREFCNT_inc(maybe_ary);
+ SvREFCNT_inc_simple_void_NN(maybe_ary);
cx->blk_loop.state_u.ary.ix =
(PL_op->op_private & OPpITER_REVERSED) ?
AvFILL(cx->blk_loop.state_u.ary.ary) + 1 :