diff options
author | Karl Williamson <khw@cpan.org> | 2019-09-19 16:03:04 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2019-11-17 21:20:07 -0700 |
commit | 13fcf6522466471a1b1c5fc2d760dd5367fd8940 (patch) | |
tree | f6272af8bf0e7308ab5792219978ab12d75d78d3 /regcomp.h | |
parent | d913538e4f136a14760fb7c73de064901acfc25b (diff) | |
download | perl-13fcf6522466471a1b1c5fc2d760dd5367fd8940.tar.gz |
Add ANYOFR regnode
This matches a single range of code points. It is both faster and
smaller than other ANYOF-type nodes, requiring, after set-up, a single
subtraction and conditional branch.
The vast majority of Unicode properties match a single range (though
most of the properties likely to be used in real world applications have
more than a single range). But things like [ij] are a single range, and
those are quite commonly encountered. This new regnode matches them more
efficiently than a bitmap would, and doesn't require the space for one
either.
The flags field is used to store the minimum matchable start byte for
UTF-8 strings, and is ignored for non-UTF-8 targets. This, like ANYOFH
nodes which have a similar mechanism, allows for quick weeding out of
many possible matches without having to convert the UTF-8 to its
corresponding code point.
This regnode packs the 32 bit argument with 20 bits for the minimum code
point the node matches, and 12 bits for the maximum range. If the input
is a value outside these, it simply won't compile to this regnode,
instead going to one of the ANYOFH flavors.
ANYOFR is sufficient to match all of Unicode except for the final
(private use) 65K plane.
Diffstat (limited to 'regcomp.h')
-rw-r--r-- | regcomp.h | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -384,6 +384,10 @@ struct regnode_ssc { ((struct regnode_string *)(p))->str_len = (v); \ } STMT_END +#define ANYOFR_BASE_BITS 20 +#define ANYOFRbase(p) (ARG(p) & ((1 << ANYOFR_BASE_BITS) - 1)) +#define ANYOFRdelta(p) (ARG(p) >> ANYOFR_BASE_BITS) + #undef NODE_ALIGN #undef ARG_LOC #undef NEXTOPER @@ -1178,7 +1182,7 @@ typedef enum { WB_BOUND } bound_type; -/* This unpacks the FLAGS field of ANYOFHx nodes. The value it contains +/* This unpacks the FLAGS field of ANYOF[HR]x nodes. The value it contains * gives the strict lower bound for the UTF-8 start byte of any code point * matchable by the node, and a loose upper bound as well. * |