diff options
author | Karl Williamson <khw@cpan.org> | 2019-03-20 11:47:15 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2019-03-20 12:12:44 -0600 |
commit | 765e6ecf32a570694dcff91c1c72f98306a9390e (patch) | |
tree | 6f2b8a6cd5bd5c4c24a80459d052d1c4f348853d /regexec.c | |
parent | 80e7c5414423d633f11ec93a7990915e97489502 (diff) | |
download | perl-765e6ecf32a570694dcff91c1c72f98306a9390e.tar.gz |
Add common UTF-8 first byte to ANYOFH regnodes
An ANYOFH regnode is generated instead of a plain ANYOF one when
nothing it can match is in the bitmap used in ANYOF nodes. It is
therefore smaller as the 4 word (or more) bitmap is omitted.
This means that for it to match a target string, that string must be
UTF-8 (since the bitmap is for at least the lowest 256 code points).
And only in rare circumstances are there any flags associated with it in
the regnode flags field.
This commit changes things so that the flags field in an ANYOFH node is
repurposed to be the first UTF-8 encoded byte of every code point
matched by the class if there is a common byte for all of them; or 0 if
some have different first bytes.
(That means that those rare cases where the flags field isn't otherwise
empty can no longer be ANYOFH nodes.)
The purpose of this is so that a future commit can take advantage of
this, and more quickly scan the target string for places that this node
can match. A problem with ANYOF nodes is that they are code point
oriented (U32 or U64), and the target string is UTF-8, so conversion has
to be done. By having the partial conversion compiled in, we can look
for that at runtime instead of having to look at every character in the
scan.
Diffstat (limited to 'regexec.c')
-rw-r--r-- | regexec.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -9744,7 +9744,7 @@ STATIC bool S_reginclass(pTHX_ regexp * const prog, const regnode * const n, const U8* const p, const U8* const p_end, const bool utf8_target) { dVAR; - const char flags = ANYOF_FLAGS(n); + const char flags = (OP(n) == ANYOFH) ? 0 : ANYOF_FLAGS(n); bool match = FALSE; UV c = *p; |