This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
for loops: don't refcount bump orig var
authorDavid Mitchell <davem@iabyn.com>
Thu, 27 Aug 2015 12:43:49 +0000 (13:43 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Feb 2016 08:59:39 +0000 (08:59 +0000)
commit88dc09d3822433b175dd40870d0509ff9b2ce901
tree4861f4e784824fafbb96b41ccf6b67d886da4cc6
parent385bbb1262443aa7e41c6e8acd6a895395459a02
for loops: don't refcount bump orig var

In something like

    for $pkg_var (...)

pp_enteriter() bumps the reference count or $pkg_var before making
itersave point to it. POPLOOP later decrements this ref count.

This bump is unnecessary; since we are effectively transferring ownership
(and thus ref count contribution) of the $pkg_var SV from the GvSV slot of
*pkg_var to the itersave slot of the context struct, the overall ref count
of the var should remain unchanged.

So skip the bump and later undo. This should make no functional difference;
it's just more efficient.
cop.h
pp_ctl.c