summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2013-01-12 10:26:15 +0000
committerDavid Mitchell <davem@iabyn.com>2013-01-12 16:34:40 +0000
commit3041a168eaf8027c9e376a53450bcb825f527da8 (patch)
treeca690cb3143ea83f3436b621f8d8a32543482b8a
parentf5d13a25262cb242090ad5e0703cf287e26156db (diff)
downloadperl-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.c8
-rw-r--r--sv.h2
2 files changed, 5 insertions, 5 deletions
diff --git a/sv.c b/sv.c
index 3b2dda8d16..dde045c125 100644
--- a/sv.c
+++ b/sv.c
@@ -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);
diff --git a/sv.h b/sv.h
index 8b07ee9b57..5e14252ccb 100644
--- a/sv.h
+++ b/sv.h
@@ -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() */