summaryrefslogtreecommitdiff
path: root/regcomp.h
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-10-30 09:44:26 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-10-30 12:36:45 -0700
commit8d919b0a35f2b57a6bed2f8355b25b19ac5ad0c5 (patch)
treedeaa4e227975359d48e1f5270ed0a82c53287875 /regcomp.h
parentf3cb5c3120c59ad2b1843ec808acee239bae8250 (diff)
downloadperl-8d919b0a35f2b57a6bed2f8355b25b19ac5ad0c5.tar.gz
Allow regexp-to-pvlv assignment
Since the xpvlv and regexp structs conflict, we have to find somewhere else to put the regexp struct. I was going to sneak it in SvPVX, allocating a buffer large enough to fit the regexp struct followed by the string, and have SvPVX - sizeof(regexp) point to the struct. But that would make all regexp flag-checking macros fatter, and those are used in hot code. So I came up with another method. Regexp stringification is not speed-critical. So we can move the regexp stringification out of re->sv_u and put it in the regexp struct. Then the regexp struct itself can be pointed to by re->sv_u. So SVt_REGEXPs will have re->sv_any and re->sv_u pointing to the same spot. PVLVs can then have sv->sv_any point to the xpvlv body as usual, but have sv->sv_u point to a regexp struct. All regexp member access can go through sv_u instead of sv_any, which will be no slower than before. Regular expressions will no longer be SvPOK, so we give sv_2pv spec- ial logic for regexps. We don’t need to make the regexp struct larger, as SvLEN is currently always 0 iff mother_re is set. So we can replace the SvLEN field with the pv. SvFAKE is never used without SvPOK or SvSCREAM also set. So we can use that to identify regexps.
Diffstat (limited to 'regcomp.h')
-rw-r--r--regcomp.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/regcomp.h b/regcomp.h
index dde4eef1f3..e9a64feea0 100644
--- a/regcomp.h
+++ b/regcomp.h
@@ -586,10 +586,10 @@ struct reg_data {
#define check_offset_max substrs->data[2].max_offset
#define check_end_shift substrs->data[2].end_shift
-#define RX_ANCHORED_SUBSTR(rx) (((struct regexp *)SvANY(rx))->anchored_substr)
-#define RX_ANCHORED_UTF8(rx) (((struct regexp *)SvANY(rx))->anchored_utf8)
-#define RX_FLOAT_SUBSTR(rx) (((struct regexp *)SvANY(rx))->float_substr)
-#define RX_FLOAT_UTF8(rx) (((struct regexp *)SvANY(rx))->float_utf8)
+#define RX_ANCHORED_SUBSTR(rx) (ReANY(rx)->anchored_substr)
+#define RX_ANCHORED_UTF8(rx) (ReANY(rx)->anchored_utf8)
+#define RX_FLOAT_SUBSTR(rx) (ReANY(rx)->float_substr)
+#define RX_FLOAT_UTF8(rx) (ReANY(rx)->float_utf8)
/* trie related stuff */