diff options
author | David Mitchell <davem@iabyn.com> | 2014-02-28 18:40:10 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2014-02-28 19:38:49 +0000 |
commit | 7532eaaef8da50c2ccee274667a2fa4a3dd6e349 (patch) | |
tree | 206ebf8696c8d5d589803ed53380191f9b52371e /scope.c | |
parent | 5c85b638cb45ea2b8e5d70bfa899f2db6085e85c (diff) | |
download | perl-7532eaaef8da50c2ccee274667a2fa4a3dd6e349.tar.gz |
SAVEt_CLEARSV: handle SvOOK() specially
Add SVf_OOK to the list of flags that are handled in the 'slow' branch.
This allows us to avoid checking for hv_kill_backrefs() or sv_backoff()
for the majority of lexicals which won't require it.
Diffstat (limited to 'scope.c')
-rw-r--r-- | scope.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -1041,16 +1041,12 @@ Perl_leave_scope(pTHX_ I32 base) /* Can clear pad variable in place? */ if (SvREFCNT(sv) <= 1 && !SvOBJECT(sv)) { - /* note that backrefs (either in HvAUX or magic) - * must be removed before other magic */ - if (SvTYPE(sv) == SVt_PVHV) - Perl_hv_kill_backrefs(aTHX_ MUTABLE_HV(sv)); - /* these flags are the union of all the relevant flags * in the individual conditions within */ if (UNLIKELY(SvFLAGS(sv) & ( SVf_READONLY /* for SvREADONLY_off() */ | (SVs_GMG|SVs_SMG|SVs_RMG) /* SvMAGICAL() */ + | SVf_OOK | SVf_THINKFIRST))) { /* if a my variable that was made readonly is @@ -1061,7 +1057,16 @@ Perl_leave_scope(pTHX_ I32 base) if (SvREADONLY(sv) && !SvFAKE(sv)) SvREADONLY_off(sv); + if (SvOOK(sv)) { /* OOK or HvAUX */ + if (SvTYPE(sv) == SVt_PVHV) + Perl_hv_kill_backrefs(aTHX_ MUTABLE_HV(sv)); + else + sv_backoff(sv); + } + if (SvMAGICAL(sv)) { + /* note that backrefs (either in HvAUX or magic) + * must be removed before other magic */ sv_unmagic(sv, PERL_MAGIC_backref); if (SvTYPE(sv) != SVt_PVCV) mg_free(sv); @@ -1093,8 +1098,6 @@ Perl_leave_scope(pTHX_ I32 base) assert_not_ROK(sv); assert_not_glob(sv); SvFLAGS(sv) &=~ (SVf_OK|SVf_IVisUV|SVf_UTF8); - if (SvOOK(sv)) - sv_backoff(sv); break; } SvPADSTALE_on(sv); /* mark as no longer live */ |