diff options
author | Steffen Mueller <smueller@cpan.org> | 2013-06-11 18:59:18 +0200 |
---|---|---|
committer | Steffen Mueller <smueller@cpan.org> | 2013-06-11 20:05:53 +0200 |
commit | 79e2a32a095274dde38cabdeca03b580bd9733d7 (patch) | |
tree | 9e0513736246e0dbe31ef7341efbf25454670b5b | |
parent | 586fc6a31347339bf2b16e391b44aa458f723283 (diff) | |
download | perl-79e2a32a095274dde38cabdeca03b580bd9733d7.tar.gz |
Branch prediction hint for SvREFCNT_dec
When decrementing the refcount on an SV, we have to branch on whether or
not we've reached a refcount of 0. But a quick instrumentation shows
that in virtually any program small or large, the number of decrements
without freeing greatly outweighs the number of decrements that cause a
free. Therefore, it's a net win to suggest to the compiler to emit a
branch prediction hint to go into the just-decrement branch.
-rw-r--r-- | inline.h | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -67,7 +67,7 @@ S_SvREFCNT_dec(pTHX_ SV *sv) { if (LIKELY(sv != NULL)) { U32 rc = SvREFCNT(sv); - if (rc > 1) + if (LIKELY(rc > 1)) SvREFCNT(sv) = rc - 1; else Perl_sv_free2(aTHX_ sv, rc); @@ -78,7 +78,7 @@ PERL_STATIC_INLINE void S_SvREFCNT_dec_NN(pTHX_ SV *sv) { U32 rc = SvREFCNT(sv); - if (rc > 1) + if (LIKELY(rc > 1)) SvREFCNT(sv) = rc - 1; else Perl_sv_free2(aTHX_ sv, rc); |