This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Don’t localise CopSTASH(&PL_compiling) in newCONSTSUB
authorFather Chrysostomos <sprout@cpan.org>
Fri, 1 Jun 2012 06:02:31 +0000 (23:02 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 5 Jun 2012 01:14:52 +0000 (18:14 -0700)
When newCONSTSUB was added in commit 5476c433, it did not set
curcop temporarily to &compiling, and so gv_fetchpv would look at
curcop->cop_stash.  So cop_stash needed to be localised.

(Time passes.... curcop is now PL_curcop.  &compiling is
now &PL_compiling.  gv_fetchpv is now gv_fetchpvn_flags.
curcop->cop_stash is now CopSTASH(PL_curcop).)

Since commit 401667e9, newCONSTSUB has set PL_curcop to &PL_compiling
temporarily.  When that is the case, gv_fetchpvn_flags uses
PL_curstash and ignores CopSTASH(PL_curcop).

So this localisation is no longer necessary, as newCONSTSUB has always
set (PL_)curstash.

op.c

diff --git a/op.c b/op.c
index 6845eba..a9516ea 100644 (file)
--- a/op.c
+++ b/op.c
@@ -6994,9 +6994,7 @@ Perl_newCONSTSUB_flags(pTHX_ HV *stash, const char *name, STRLEN len,
 
     if (stash) {
        SAVEGENERICSV(PL_curstash);
-       SAVECOPSTASH(PL_curcop);
        PL_curstash = (HV *)SvREFCNT_inc_simple_NN(stash);
-       CopSTASH_set(PL_curcop,stash);
     }
 
     /* file becomes the CvFILE. For an XS, it's usually static storage,
@@ -7008,10 +7006,6 @@ Perl_newCONSTSUB_flags(pTHX_ HV *stash, const char *name, STRLEN len,
     CvXSUBANY(cv).any_ptr = sv;
     CvCONST_on(cv);
 
-#ifdef USE_ITHREADS
-    if (stash)
-       CopSTASH_free(PL_curcop);
-#endif
     LEAVE;
 
     return cv;