diff options
author | David Mitchell <davem@iabyn.com> | 2013-01-12 10:26:15 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2013-01-12 16:34:40 +0000 |
commit | 3041a168eaf8027c9e376a53450bcb825f527da8 (patch) | |
tree | ca690cb3143ea83f3436b621f8d8a32543482b8a | |
parent | f5d13a25262cb242090ad5e0703cf287e26156db (diff) | |
download | perl-3041a168eaf8027c9e376a53450bcb825f527da8.tar.gz |
include SvREADONLY() in SvIMMORTAL() test
SvIMMORTAL() is currently defined as
((sv)==&PL_sv_undef || (sv)==&PL_sv_yes
|| (sv)==&PL_sv_no || (sv)==&PL_sv_placeholder)
Which is relatively slow. Some places do this:
if (SvREADONLY(sv) && SvIMMORTAL(sv)) ...
which quickly rejects most times.
This commit simply moves the SvREADONLY test into the SvIMMORTAL macro
so that *all* uses benefit from this speedup.
-rw-r--r-- | sv.c | 8 | ||||
-rw-r--r-- | sv.h | 2 |
2 files changed, 5 insertions, 5 deletions
@@ -6409,7 +6409,7 @@ Perl_sv_clear(pTHX_ SV *const orig_sv) continue; } #endif - if (SvREADONLY(sv) && SvIMMORTAL(sv)) { + if (SvIMMORTAL(sv)) { /* make sure SvREFCNT(sv)==0 happens very seldom */ SvREFCNT(sv) = SvREFCNT_IMMORTAL; continue; @@ -6575,7 +6575,7 @@ Perl_sv_free2(pTHX_ SV *const sv, const U32 rc) return; } #endif - if (SvREADONLY(sv) && SvIMMORTAL(sv)) { + if (SvIMMORTAL(sv)) { /* make sure SvREFCNT(sv)==0 happens very seldom */ SvREFCNT(sv) = SvREFCNT_IMMORTAL; return; @@ -6596,7 +6596,7 @@ Perl_sv_free2(pTHX_ SV *const sv, const U32 rc) return; if (PL_in_clean_all) /* All is fair */ return; - if (SvREADONLY(sv) && SvIMMORTAL(sv)) { + if (SvIMMORTAL(sv)) { /* make sure SvREFCNT(sv)==0 happens very seldom */ SvREFCNT(sv) = SvREFCNT_IMMORTAL; return; @@ -8572,7 +8572,7 @@ Perl_sv_2mortal(pTHX_ SV *const sv) dVAR; if (!sv) return NULL; - if (SvREADONLY(sv) && SvIMMORTAL(sv)) + if (SvIMMORTAL(sv)) return sv; PUSH_EXTEND_MORTAL__SV_C(sv); SvTEMP_on(sv); @@ -2061,7 +2061,7 @@ alternative is to call C<sv_grow> if you are not sure of the type of SV. #define SvPEEK(sv) "" #endif -#define SvIMMORTAL(sv) ((sv)==&PL_sv_undef || (sv)==&PL_sv_yes || (sv)==&PL_sv_no || (sv)==&PL_sv_placeholder) +#define SvIMMORTAL(sv) (SvREADONLY(sv) && ((sv)==&PL_sv_undef || (sv)==&PL_sv_yes || (sv)==&PL_sv_no || (sv)==&PL_sv_placeholder)) #ifdef DEBUGGING /* exercise the immortal resurrection code in sv_free2() */ |