diff options
-rw-r--r-- | pp_ctl.c | 1 | ||||
-rw-r--r-- | pp_hot.c | 9 |
2 files changed, 9 insertions, 1 deletions
@@ -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); @@ -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; } |