This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Simplify S_return_lvalues()
authorDavid Mitchell <davem@iabyn.com>
Tue, 9 Jun 2015 09:31:10 +0000 (10:31 +0100)
committerDavid Mitchell <davem@iabyn.com>
Fri, 19 Jun 2015 07:44:17 +0000 (08:44 +0100)
commite80c4acfa42a94f2871cd8778da458d8d1942385
treeb08ef600ca9130ab7bcab8859e8bf6e39e231d6c
parentc32ac924c5334939c7184c773ea5d07478b5df99
Simplify S_return_lvalues()

S_return_lvalues() was written to handle both pp_leavesublv and pp_return;
in the latter case there could be junk on the stack that needs skipping;
e.g.

    for (1,2) { return 3,4 }

leaves 1,2,3,4 on the stack, and in list context the 3,4 needs shifting
down two places. After the previous commit, any return-specific processing
is now handled by pp_return itself, so S_return_lvalues only has to
worry about mortalising its args and grabbing the last arg in scalar
context.

Formerly there were two vars: newsp, which pointed to the slot before the
'1', and MARK, which pointed to the slot before the '3'. They now both
point to just before the '1'. So we only need to use one of them. Here
I've standardised on MARK, to make the code as similar as possible to that
in pp_leavesub, from which this code was forked back in 1999. For the same
reason I've set MARK to point to the '1' slot rather than the slot before
it, since that's what pp_leavesub does.
pp_ctl.c