regex free up bit in ANYOF node
authorKarl Williamson <public@khwilliamson.com>
Fri, 12 Nov 2010 03:07:09 +0000 (20:07 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 22 Nov 2010 21:32:50 +0000 (13:32 -0800)
commitcefafd73018b048fa66d2b22250431112141955a
tree3fceda48445d91fea7e34f4e6a5a74a5a2588a30
parentc355c09a82f4c7345a6bafa5322643acdb584e80
regex free up bit in ANYOF node

This patch causes all locale ANYOF nodes to have a class bitmap (4
bytes) even if they don't have a class (such as \w, \d, [:posix:]).
This frees up a bit in the flags field that was used to signal if the
node had the bitmap.  I intend to use it instead to signal that loading
a swash, which is slow, can be bypassed.  Thus this is a time/space
tradeoff, applicable to not just locale nodes: adding a word to the
locale nodes saves time for all nodes.

I added the ANYOF_CLASS_TEST_ANY_SET() macro to determine quickly if
there are actually any classes in the node.

Minimal code was changed, so this can be easily reversed if another bit
frees up.

Another possibility is to share with the ANYOF_EOS bit instead, as this
is used just in the optimizer's start class, and only in regcomp.c.  But
this requires more careful coding.

Another possibility is to add a byte (hence likely at least 4 because of
alignment issues) to store extra flags.

And still another possibility is to add just the byte for the start
class, which would not need to affect other ANYOF nodes, since the EOS
bit is not used outside regcomp.c.  But various routines in regcomp
assume that the start class and other ANYOF nodes are interchangeable,
so this option would require more code changes.
regcomp.c
regcomp.h
regexec.c