summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pp_ctl.c1
-rw-r--r--pp_hot.c9
2 files changed, 9 insertions, 1 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index bdc371f047..b1d2f68dc2 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1388,6 +1388,7 @@ PP(pp_enteriter)
croak("Range iterator outside integer range");
cx->blk_loop.iterix = SvIV(sv);
cx->blk_loop.itermax = SvIV((SV*)cx->blk_loop.iterary);
+ sv_setiv(*svp, 0); /* make sure index SV is IV capable */
}
else
cx->blk_loop.iterlval = newSVsv(sv);
diff --git a/pp_hot.c b/pp_hot.c
index b52563a38f..f7183a8f12 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1459,7 +1459,14 @@ PP(pp_iter)
/* integer increment */
if (cx->blk_loop.iterix > cx->blk_loop.itermax)
RETPUSHNO;
- sv_setiv(*cx->blk_loop.itervar, cx->blk_loop.iterix++);
+
+ /* we know that the loop index SV is IV capable, so we can save
+ * some time by doing the essential work of sv_setiv() ourself.
+ */
+ sv = *cx->blk_loop.itervar;
+ (void)SvIOK_only(sv);
+ SvIVX(sv) = cx->blk_loop.iterix++;
+
RETPUSHYES;
}