From: Gisle Aas Date: Tue, 7 Jul 1998 11:48:11 +0000 (+0200) Subject: Faster foreach integer range X-Git-Tag: accepted/trunk/20130322.191538~37437 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d426b052dee31c20224ef2893d5c969ad5a2c617;p=platform%2Fupstream%2Fperl.git Faster foreach integer range Message-ID: p4raw-id: //depot/perl@1367 --- diff --git a/pp_ctl.c b/pp_ctl.c index bdc371f..b1d2f68 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 b52563a..f7183a8 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; }