Free temps on recursive scalar lvalue sub exit
authorFather Chrysostomos <sprout@cpan.org>
Sat, 9 Jul 2011 12:50:04 +0000 (05:50 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 9 Jul 2011 13:13:39 +0000 (06:13 -0700)
See the thread starting at
<83877DD1-4624-4497-B784-0F8DA25DB4A8@cpan.org>.

I still don’t know why this does not apply to list context.

As with most lvalue sub fixes, this involves deleting code.

pod/perldelta.pod
pp_ctl.c

index 6ba42eb..6e3f67c 100644 (file)
@@ -97,6 +97,11 @@ C<study> now uses considerably less memory for shorter strings. Strings shorter
 than 65535 characters use roughly half the memory than previously, strings
 shorter than 255 characters use roughly one quarter of the memory.
 
+=item *
+
+Recursive calls to lvalue subroutines in lvalue scalar context use less
+memory.
+
 =back
 
 =head1 Modules and Pragmata
index 0727372..554e47f 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2313,12 +2313,6 @@ S_return_lvalues(pTHX_ SV **mark, SV **sp, SV **newsp, I32 gimme,
                        SvREADONLY(TOPs) ? (TOPs == &PL_sv_undef) ? "undef"
                        : "a readonly value" : "a temporary");
                }
-               else {                  /* Can be a localized value
-                   EXTEND_MORTAL(1);    * subject to deletion. */
-                   PL_tmps_stack[++PL_tmps_ix] = *SP;
-                   SvREFCNT_inc_void(*SP);
-                   *++newsp = *SP;
-               }
            }
            else {
                /* sub:lvalue{} will take us here. */
@@ -2333,7 +2327,7 @@ S_return_lvalues(pTHX_ SV **mark, SV **sp, SV **newsp, I32 gimme,
                );
            }
        }
-       else if (MARK < SP) {
+       if (MARK < SP) {
                if (cx->blk_sub.cv && CvDEPTH(cx->blk_sub.cv) > 1) {
                        *++newsp = SvREFCNT_inc(*SP);
                        FREETMPS;