When dup'ing CVs, only take the OP_REFCNT_LOCK if it is needed.
authorNicholas Clark <nick@ccl4.org>
Tue, 23 Nov 2010 11:48:51 +0000 (11:48 +0000)
committerNicholas Clark <nick@ccl4.org>
Tue, 23 Nov 2010 13:20:19 +0000 (13:20 +0000)
Previously it was being taken for all CVs, including XSUBS.

Also, refactor other non-XSUB specific code into the same if block.

sv.c

diff --git a/sv.c b/sv.c
index 5705890..b62eba9 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -11892,11 +11892,12 @@ S_sv_dup_common(pTHX_ const SV *const sstr, CLONE_PARAMS *const param)
                    hv_dup(CvSTASH(dstr), param);
                if ((param->flags & CLONEf_JOIN_IN) && CvSTASH(dstr))
                    Perl_sv_add_backref(aTHX_ MUTABLE_SV(CvSTASH(dstr)), dstr);
-               OP_REFCNT_LOCK;
-               if (!CvISXSUB(dstr))
+               if (!CvISXSUB(dstr)) {
+                   OP_REFCNT_LOCK;
                    CvROOT(dstr) = OpREFCNT_inc(CvROOT(dstr));
-               OP_REFCNT_UNLOCK;
-               if (CvCONST(dstr) && CvISXSUB(dstr)) {
+                   OP_REFCNT_UNLOCK;
+                   CvFILE(dstr) = SAVEPV(CvFILE(dstr));
+               } else if (CvCONST(dstr)) {
                    CvXSUBANY(dstr).any_ptr =
                        sv_dup_inc((const SV *)CvXSUBANY(dstr).any_ptr, param);
                }
@@ -11914,8 +11915,6 @@ S_sv_dup_common(pTHX_ const SV *const sstr, CLONE_PARAMS *const param)
                    CvWEAKOUTSIDE(sstr)
                    ? cv_dup(    CvOUTSIDE(dstr), param)
                    : cv_dup_inc(CvOUTSIDE(dstr), param);
-               if (!CvISXSUB(dstr))
-                   CvFILE(dstr) = SAVEPV(CvFILE(dstr));
                break;
            }
        }