This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_iter: refactor CXt_LOOP_LAZYSV branch
authorDavid Mitchell <davem@iabyn.com>
Tue, 13 Nov 2012 13:12:31 +0000 (13:12 +0000)
committerDavid Mitchell <davem@iabyn.com>
Thu, 15 Nov 2012 22:41:07 +0000 (22:41 +0000)
pp_hot.c

index 25c3810..3967b9c 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1917,16 +1917,16 @@ PP(pp_iter)
            if (SvNIOK(cur) || SvCUR(cur) > maxlen)
                 RETPUSHNO;
 
-            if (SvREFCNT(*itersvp) == 1 && !SvMAGICAL(*itersvp)) {
+            oldsv = *itersvp;
+            if (SvREFCNT(oldsv) == 1 && !SvMAGICAL(oldsv)) {
                 /* safe to reuse old SV */
-                sv_setsv(*itersvp, cur);
+                sv_setsv(oldsv, cur);
             }
             else
             {
                 /* we need a fresh SV every time so that loop body sees a
                  * completely new SV for closures/references to work as
                  * they used to */
-                oldsv = *itersvp;
                 *itersvp = newSVsv(cur);
                 SvREFCNT_dec(oldsv);
             }