summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-11-23 11:48:51 +0000
committerNicholas Clark <nick@ccl4.org>2010-11-23 13:20:19 +0000
commitf352ce091c525153812f67ed208da9d9e6544625 (patch)
treed9136f76b2f8b102d164fa5d59cf55b80a57c7e7 /sv.c
parent7aaef02a1f50c8f5944af8dd33fc7de19986553f (diff)
downloadperl-f352ce091c525153812f67ed208da9d9e6544625.tar.gz
When dup'ing CVs, only take the OP_REFCNT_LOCK if it is needed.
Previously it was being taken for all CVs, including XSUBS. Also, refactor other non-XSUB specific code into the same if block.
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/sv.c b/sv.c
index 5705890ef3..b62eba9819 100644
--- 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;
}
}