summaryrefslogtreecommitdiff
path: root/inline.h
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2012-12-04 11:32:39 +0000
committerDavid Mitchell <davem@iabyn.com>2012-12-04 11:32:39 +0000
commit4a9a56a75c57646b348598f90875415e994d2f65 (patch)
treec6b563b3f66247d8ef7596f8010bd6b4fd1c50f6 /inline.h
parent75a9bf9690b77515a287eb483ea2709b73810c41 (diff)
downloadperl-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.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/inline.h b/inline.h
index 5e11b69122..776a30499e 100644
--- a/inline.h
+++ b/inline.h
@@ -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));