diff options
author | David Mitchell <davem@iabyn.com> | 2012-12-04 11:32:39 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2012-12-04 11:32:39 +0000 |
commit | 4a9a56a75c57646b348598f90875415e994d2f65 (patch) | |
tree | c6b563b3f66247d8ef7596f8010bd6b4fd1c50f6 /inline.h | |
parent | 75a9bf9690b77515a287eb483ea2709b73810c41 (diff) | |
download | perl-4a9a56a75c57646b348598f90875415e994d2f65.tar.gz |
add SvREFCNT_dec_NN()
Like SvREFCNT_dec(), but skips the not null check, making code potentially
smaller and faster.
Also as proof of concept, updates the SvREFCNT_dec's in scope.c where
it's obvious the value can't be NULL. There are still 500+ uses in the
perl core that need evaluating!
Diffstat (limited to 'inline.h')
-rw-r--r-- | inline.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -64,6 +64,16 @@ S_SvREFCNT_dec(pTHX_ SV *sv) } PERL_STATIC_INLINE void +S_SvREFCNT_dec_NN(pTHX_ SV *sv) +{ + U32 rc = SvREFCNT(sv); + if (rc > 1) + SvREFCNT(sv) = rc - 1; + else + Perl_sv_free2(aTHX_ sv, rc); +} + +PERL_STATIC_INLINE void SvAMAGIC_on(SV *sv) { assert(SvROK(sv)); |