regexec.c: Use shared swash in bracketed character classes
authorKarl Williamson <public@khwilliamson.com>
Fri, 6 Jan 2012 04:15:45 +0000 (21:15 -0700)
committerKarl Williamson <public@khwilliamson.com>
Fri, 13 Jan 2012 16:58:39 +0000 (09:58 -0700)
This takes advantage of an earlier commit to use a swash that may be
shared across multiple character class instances.  That means that if a
match in another class has to look up a value, that that same value is
automatically available without further lookup to all character classes
that share the swash.  This means that the lookup result only needs be
cached once for all instances in the thread, saving time and memory.

Note that currently the only swashes that are shared are those that
consist solely of a single Unicode property definition.  Some sort of
checksum would have to be computed if this were to be extended to
custom classes.  But what this does is cause sharing for all Unicode
properties that aren't in bracketed classes (as they are implemented as
a bracketed class with a single element), as well as the few cases where
someone explicitly writes [\p{foo}] without anything else in the class.

regexec.c

index 4275b37..1bb0cea 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -6733,7 +6733,7 @@ S_reginclass(pTHX_ const regexp * const prog, register const regnode * const n,
                             || (flags & ANYOF_IS_SYNTHETIC)))))
        {
            AV *av;
-           SV * const sw = regclass_swash(prog, n, TRUE, 0, (SV**)&av);
+           SV * const sw = core_regclass_swash(prog, n, TRUE, 0, (SV**)&av);
 
            if (sw) {
                U8 * utf8_p;