diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-06-20 14:23:02 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-06-20 15:54:05 -0700 |
commit | a0d2bbd5c47035a4f7369e4fddd46b502764d86e (patch) | |
tree | 175a61f41be9b43ee8d21ada2d05a4748cbf717a /pad.c | |
parent | 60d91a71fad08b06816b91400592863df5f10d47 (diff) | |
download | perl-a0d2bbd5c47035a4f7369e4fddd46b502764d86e.tar.gz |
[perl #89544] Non-eval closures don’t need CvOUTSIDE
A closure doesn’t need an outside pointer at run time, unless it has a
string eval in it. CvOUTSIDE is only used at compilation time to look
up variables by name.
Since CvOUTSIDE is reference-counted, a closure can unnecessarily hang
on to variables it is not using (see the test in the diff). So stop
setting it when cloning a closure, unless it is needed for eval.
Diffstat (limited to 'pad.c')
-rw-r--r-- | pad.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -1624,6 +1624,7 @@ Perl_pad_tidy(pTHX_ padtidy_type type) DEBUG_Xv(PerlIO_printf(Perl_debug_log, "Pad clone on cv=0x%"UVxf"\n", PTR2UV(cv))); CvCLONE_on(cv); + CvHASEVAL_on(cv); } } } @@ -1902,7 +1903,8 @@ Perl_cv_clone(pTHX_ CV *proto) CvROOT(cv) = OpREFCNT_inc(CvROOT(proto)); OP_REFCNT_UNLOCK; CvSTART(cv) = CvSTART(proto); - CvOUTSIDE(cv) = MUTABLE_CV(SvREFCNT_inc_simple(outside)); + if (CvHASEVAL(cv)) + CvOUTSIDE(cv) = MUTABLE_CV(SvREFCNT_inc_simple(outside)); CvOUTSIDE_SEQ(cv) = CvOUTSIDE_SEQ(proto); if (SvPOK(proto)) |