summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2016-11-12 13:19:58 +0000
committerDavid Mitchell <davem@iabyn.com>2016-11-12 16:15:09 +0000
commitb4204fb6f01f49bdf8ebb6d68e0f713a505f069a (patch)
treec54d4db80ac36e6f9d649fc74784848dbac8399d
parente08d24ff56cda24d8146e29d00376eb23eedbd7e (diff)
downloadperl-b4204fb6f01f49bdf8ebb6d68e0f713a505f069a.tar.gz
eliminate SVpbm_TAIL/SvTAIL_on()/SvTAIL_off()
(but keep SvTAIL()) This flag is only set on SVs that have Boyer-Moore magic attached. Such SVs already re-purpose the unused IVX slot of that SV to store BmUSEFUL. This commit repurposes the unused NVX slot to store this boolean value instead. Now that flag bit (0x80000000) is only used with AVs, HVs, RVs and scalar SVs with IOK.
-rw-r--r--mg.c1
-rw-r--r--sv.h16
-rw-r--r--util.c3
3 files changed, 7 insertions, 13 deletions
diff --git a/mg.c b/mg.c
index a0ee39d234..a5530c0acd 100644
--- a/mg.c
+++ b/mg.c
@@ -2445,7 +2445,6 @@ Perl_magic_setregexp(pTHX_ SV *sv, MAGIC *mg)
if (type == PERL_MAGIC_qr) {
} else if (type == PERL_MAGIC_bm) {
- SvTAIL_off(sv);
SvVALID_off(sv);
} else {
assert(type == PERL_MAGIC_fm);
diff --git a/sv.h b/sv.h
index e2cf10e373..777ca38495 100644
--- a/sv.h
+++ b/sv.h
@@ -463,8 +463,6 @@ perform the upgrade if necessary. See C<L</svtype>>.
#define SVpav_REIFY 0x80000000 /* can become real */
/* PVHV */
#define SVphv_HASKFLAGS 0x80000000 /* keys have flag byte after hash */
-/* PVGV when SVpbm_VALID is true */
-#define SVpbm_TAIL 0x80000000 /* string has a fake "\n" appended */
/* RV upwards. However, SVf_ROK and SVp_IOK are exclusive */
#define SVprv_WEAKREF 0x80000000 /* Weak reference */
/* pad name vars only */
@@ -484,6 +482,7 @@ union _xnvu {
NV xnv_nv; /* numeric value, if any */
HV * xgv_stash;
line_t xnv_lines; /* used internally by S_scan_subst() */
+ bool xnv_bm_tail; /* an SvVALID (BM) SV has an implicit "\n" */
};
union _xivu {
@@ -491,6 +490,7 @@ union _xivu {
UV xivu_uv;
HEK * xivu_namehek; /* xpvlv, xpvgv: GvNAME */
bool xivu_eval_seen; /* used internally by S_scan_subst() */
+
};
union _xmgu {
@@ -1139,21 +1139,17 @@ object type. Exposed to perl code via Internals::SvREADONLY().
# define SvTAIL(sv) ({ const SV *const _svtail = (const SV *)(sv); \
assert(SvTYPE(_svtail) != SVt_PVAV); \
assert(SvTYPE(_svtail) != SVt_PVHV); \
- assert(!SvSCREAM(_svtail)); \
- assert((SvFLAGS(sv) & SVpbm_VALID)); \
- (SvFLAGS(sv) & (SVpbm_TAIL|SVpbm_VALID)) \
- == (SVpbm_TAIL|SVpbm_VALID); \
+ assert((SvFLAGS(_svtail) & SVpbm_VALID)); \
+ assert(!(SvFLAGS(_svtail) & (SVf_NOK|SVp_NOK))); \
+ ((XPVNV*)SvANY(_svtail))->xnv_u.xnv_bm_tail; \
})
#else
# define SvVALID(sv) ((SvFLAGS(sv) & SVpbm_VALID) && !SvSCREAM(sv))
# define SvVALID_on(sv) (SvFLAGS(sv) |= SVpbm_VALID)
# define SvVALID_off(sv) (SvFLAGS(sv) &= ~SVpbm_VALID)
-# define SvTAIL(sv) ((SvFLAGS(sv) & (SVpbm_TAIL|SVpbm_VALID)) \
- == (SVpbm_TAIL|SVpbm_VALID))
+# define SvTAIL(_svtail) (((XPVNV*)SvANY(_svtail))->xnv_u.xnv_bm_tail)
#endif
-#define SvTAIL_on(sv) (SvFLAGS(sv) |= SVpbm_TAIL)
-#define SvTAIL_off(sv) (SvFLAGS(sv) &= ~SVpbm_TAIL)
#define SvRVx(sv) SvRV(sv)
diff --git a/util.c b/util.c
index 409d3ec48f..e459a0c5da 100644
--- a/util.c
+++ b/util.c
@@ -780,8 +780,7 @@ Perl_fbm_compile(pTHX_ SV *sv, U32 flags)
}
}
BmUSEFUL(sv) = 100; /* Initial value */
- if (flags & FBMcf_TAIL)
- SvTAIL_on(sv);
+ ((XPVNV*)SvANY(sv))->xnv_u.xnv_bm_tail = cBOOL(flags & FBMcf_TAIL);
DEBUG_r(PerlIO_printf(Perl_debug_log, "rarest char %c at %"UVuf"\n",
s[rarest], (UV)rarest));
}