This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Delay some initialization until needed
authorKarl Williamson <public@khwilliamson.com>
Sat, 7 Jul 2012 17:42:30 +0000 (11:42 -0600)
committerKarl Williamson <public@khwilliamson.com>
Wed, 25 Jul 2012 03:13:46 +0000 (21:13 -0600)
This delays the initialization of the bitmap in ANYOF nodes until just
before it is needed, and to after where we make a decision to optimize
that node to a node which takes less space.  Currently, the space is
not given up, once reserved in pass 1, so the write is harmless.  This
will allow a future commit to shrink the space.

regcomp.c

index 2e23fa9..d5d1cb9 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -11155,7 +11155,6 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, U32 depth)
        if (LOC) {
            ANYOF_FLAGS(ret) |= ANYOF_LOCALE;
        }
-       ANYOF_BITMAP_ZERO(ret);
        listsv = newSVpvs("# comment\n");
        initial_listsv_len = SvCUR(listsv);
     }
@@ -12315,6 +12314,7 @@ parseit:
      * compile time that match under all conditions.  Go through it, and
      * for things that belong in the bitmap, put them there, and delete from
      * <cp_list> */
+    ANYOF_BITMAP_ZERO(ret);
     if (cp_list) {
 
        /* This gets set if we actually need to modify things */