This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Use an array for some inversion lists
authorKarl Williamson <public@khwilliamson.com>
Thu, 13 Dec 2012 17:39:53 +0000 (10:39 -0700)
committerKarl Williamson <public@khwilliamson.com>
Sat, 22 Dec 2012 18:11:29 +0000 (11:11 -0700)
Previous commits have placed some inversion list pointers into arrays.
This commit extends that to another group of inversion lists

embedvar.h
intrpvar.h
perl.c
regcomp.c
sv.c

index 9dca404..6b1775c 100644 (file)
 #define PL_Sock                        (vTHX->ISock)
 #define PL_StdIO               (vTHX->IStdIO)
 #define PL_Sv                  (vTHX->ISv)
-#define PL_VertSpace           (vTHX->IVertSpace)
-#define PL_XPerlSpace          (vTHX->IXPerlSpace)
-#define PL_XPosixBlank         (vTHX->IXPosixBlank)
-#define PL_XPosixCntrl         (vTHX->IXPosixCntrl)
-#define PL_XPosixSpace         (vTHX->IXPosixSpace)
-#define PL_XPosixXDigit                (vTHX->IXPosixXDigit)
+#define PL_XPosix_ptrs         (vTHX->IXPosix_ptrs)
 #define PL_Xpv                 (vTHX->IXpv)
 #define PL_an                  (vTHX->Ian)
 #define PL_apiversion          (vTHX->Iapiversion)
index aabf454..2cc1ff3 100644 (file)
@@ -566,13 +566,7 @@ PERLVAR(I, ASCII,  SV *)
 PERLVAR(I, Latin1,     SV *)
 PERLVAR(I, AboveLatin1,        SV *)
 
-PERLVAR(I, XPerlSpace, SV *)
-PERLVAR(I, XPosixBlank,        SV *)
 PERLVAR(I, L1Cased,    SV *)
-PERLVAR(I, XPosixCntrl,        SV *)
-PERLVAR(I, XPosixSpace,        SV *)
-PERLVAR(I, XPosixXDigit, SV *)
-PERLVAR(I, VertSpace,   SV *)
 
 PERLVAR(I, NonL1NonFinalFold,   SV *)
 PERLVAR(I, HasMultiCharFold,   SV *)
@@ -591,6 +585,8 @@ PERLVAR(I, utf8_charname_continue, SV *)
 PERLVARA(I, utf8_swash_ptrs, POSIX_SWASH_COUNT, SV *)
 PERLVARA(I, Posix_ptrs, POSIX_CC_COUNT, SV *)
 PERLVARA(I, L1Posix_ptrs, POSIX_CC_COUNT, SV *)
+PERLVARA(I, XPosix_ptrs, POSIX_CC_COUNT, SV *)
+
 PERLVAR(I, last_swash_hv, HV *)
 PERLVAR(I, last_swash_tmps, U8 *)
 PERLVAR(I, last_swash_slen, STRLEN)
diff --git a/perl.c b/perl.c
index 283ba90..5751704 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -1008,6 +1008,9 @@ perl_destruct(pTHXx)
 
         SvREFCNT_dec(PL_L1Posix_ptrs[i]);
         PL_L1Posix_ptrs[i] = NULL;
+
+        SvREFCNT_dec(PL_XPosix_ptrs[i]);
+        PL_XPosix_ptrs[i] = NULL;
     }
 
     if (!specialWARN(PL_compiling.cop_warnings))
index e435876..76a62c4 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -5349,11 +5349,11 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
        PL_Posix_ptrs[_CC_ALPHA] = _new_invlist_C_array(PosixAlpha_invlist);
 
        PL_Posix_ptrs[_CC_BLANK] = _new_invlist_C_array(PosixBlank_invlist);
-       PL_XPosixBlank = _new_invlist_C_array(XPosixBlank_invlist);
+       PL_XPosix_ptrs[_CC_BLANK] = _new_invlist_C_array(XPosixBlank_invlist);
        PL_L1Cased = _new_invlist_C_array(L1Cased_invlist);
 
        PL_Posix_ptrs[_CC_CNTRL] = _new_invlist_C_array(PosixCntrl_invlist);
-       PL_XPosixCntrl = _new_invlist_C_array(XPosixCntrl_invlist);
+       PL_XPosix_ptrs[_CC_CNTRL] = _new_invlist_C_array(XPosixCntrl_invlist);
 
        PL_Posix_ptrs[_CC_DIGIT] = _new_invlist_C_array(PosixDigit_invlist);
 
@@ -5370,21 +5370,21 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
        PL_Posix_ptrs[_CC_PUNCT] = _new_invlist_C_array(PosixPunct_invlist);
 
        PL_Posix_ptrs[_CC_SPACE] = _new_invlist_C_array(PerlSpace_invlist);
-       PL_XPerlSpace = _new_invlist_C_array(XPerlSpace_invlist);
+       PL_XPosix_ptrs[_CC_SPACE] = _new_invlist_C_array(XPerlSpace_invlist);
        PL_Posix_ptrs[_CC_PSXSPC] = _new_invlist_C_array(PosixSpace_invlist);
-       PL_XPosixSpace = _new_invlist_C_array(XPosixSpace_invlist);
+       PL_XPosix_ptrs[_CC_PSXSPC] = _new_invlist_C_array(XPosixSpace_invlist);
 
        PL_L1Posix_ptrs[_CC_UPPER] = _new_invlist_C_array(L1PosixUpper_invlist);
        PL_Posix_ptrs[_CC_UPPER] = _new_invlist_C_array(PosixUpper_invlist);
 
-       PL_VertSpace = _new_invlist_C_array(VertSpace_invlist);
+        PL_XPosix_ptrs[_CC_VERTSPACE] = _new_invlist_C_array(VertSpace_invlist);
 
        PL_Posix_ptrs[_CC_WORDCHAR] = _new_invlist_C_array(PosixWord_invlist);
        PL_L1Posix_ptrs[_CC_WORDCHAR]
                                 = _new_invlist_C_array(L1PosixWord_invlist);
 
        PL_Posix_ptrs[_CC_XDIGIT] = _new_invlist_C_array(PosixXDigit_invlist);
-       PL_XPosixXDigit = _new_invlist_C_array(XPosixXDigit_invlist);
+       PL_XPosix_ptrs[_CC_XDIGIT] = _new_invlist_C_array(XPosixXDigit_invlist);
 
         PL_HasMultiCharFold = _new_invlist_C_array(_Perl_Multi_Char_Folds_invlist);
     }
@@ -11975,7 +11975,7 @@ parseit:
                case ANYOF_BLANK:
                     if (hasISBLANK || ! LOC) {
                         DO_POSIX(ret, namedclass, posixes,
-                                            PL_Posix_ptrs[classnum], PL_XPosixBlank);
+                                            PL_Posix_ptrs[classnum], PL_XPosix_ptrs[classnum]);
                     }
                     else { /* There is no isblank() and we are in locale:  We
                               use the ASCII range and the above-Latin1 range
@@ -11984,7 +11984,7 @@ parseit:
 
                         /* Include all above-Latin1 blanks */
                         _invlist_intersection(PL_AboveLatin1,
-                                              PL_XPosixBlank,
+                                              PL_XPosix_ptrs[classnum],
                                               &scratch_list);
                         /* Add it to the running total of posix classes */
                         if (! posixes) {
@@ -12001,17 +12001,17 @@ parseit:
                case ANYOF_NBLANK:
                     if (hasISBLANK || ! LOC) {
                         DO_N_POSIX(ret, namedclass, posixes,
-                                                PL_Posix_ptrs[classnum], PL_XPosixBlank);
+                                                PL_Posix_ptrs[classnum], PL_XPosix_ptrs[classnum]);
                     }
                     else { /* There is no isblank() and we are in locale */
                         SV* scratch_list = NULL;
 
                         /* Include all above-Latin1 non-blanks */
-                        _invlist_subtract(PL_AboveLatin1, PL_XPosixBlank,
+                        _invlist_subtract(PL_AboveLatin1, PL_XPosix_ptrs[classnum],
                                           &scratch_list);
 
                         /* Add them to the running total of posix classes */
-                        _invlist_subtract(PL_AboveLatin1, PL_XPosixBlank,
+                        _invlist_subtract(PL_AboveLatin1, PL_XPosix_ptrs[classnum],
                                           &scratch_list);
                         if (! posixes) {
                             posixes = scratch_list;
@@ -12031,11 +12031,11 @@ parseit:
                    break;
                case ANYOF_CNTRL:
                     DO_POSIX(ret, namedclass, posixes,
-                                            PL_Posix_ptrs[classnum], PL_XPosixCntrl);
+                                            PL_Posix_ptrs[classnum], PL_XPosix_ptrs[classnum]);
                    break;
                case ANYOF_NCNTRL:
                     DO_N_POSIX(ret, namedclass, posixes,
-                                            PL_Posix_ptrs[classnum], PL_XPosixCntrl);
+                                            PL_Posix_ptrs[classnum], PL_XPosix_ptrs[classnum]);
                    break;
                case ANYOF_DIGIT:
                    /* There are no digits in the Latin1 range outside of
@@ -12055,11 +12055,11 @@ parseit:
                     * if these characters had folds other than themselves, as
                     * cp_list is subject to folding.  It turns out that \h
                     * is just a synonym for XPosixBlank */
-                   _invlist_union(cp_list, PL_XPosixBlank, &cp_list);
+                   _invlist_union(cp_list, PL_XPosix_ptrs[_CC_BLANK], &cp_list);
                    break;
                case ANYOF_NHORIZWS:
                     _invlist_union_complement_2nd(cp_list,
-                                                 PL_XPosixBlank, &cp_list);
+                                                 PL_XPosix_ptrs[_CC_BLANK], &cp_list);
                    break;
                case ANYOF_LOWER:
                case ANYOF_NLOWER:
@@ -12099,38 +12099,39 @@ parseit:
                }
                case ANYOF_PSXSPC:
                     DO_POSIX(ret, namedclass, posixes,
-                                            PL_Posix_ptrs[classnum], PL_XPosixSpace);
+                                            PL_Posix_ptrs[classnum], PL_XPosix_ptrs[classnum]);
                    break;
                case ANYOF_NPSXSPC:
                     DO_N_POSIX(ret, namedclass, posixes,
-                                            PL_Posix_ptrs[classnum], PL_XPosixSpace);
+                                            PL_Posix_ptrs[classnum], PL_XPosix_ptrs[classnum]);
                    break;
                case ANYOF_SPACE:
                     DO_POSIX(ret, namedclass, posixes,
-                                            PL_Posix_ptrs[classnum], PL_XPerlSpace);
+                                            PL_Posix_ptrs[classnum], PL_XPosix_ptrs[classnum]);
                    break;
                case ANYOF_NSPACE:
                     DO_N_POSIX(ret, namedclass, posixes,
-                                            PL_Posix_ptrs[classnum], PL_XPerlSpace);
+                                            PL_Posix_ptrs[classnum], PL_XPosix_ptrs[classnum]);
                    break;
                case ANYOF_VERTWS:
                    /* For these, we use the cp_list, as /d doesn't make a
                     * difference in what these match.  There would be problems
                     * if these characters had folds other than themselves, as
                     * cp_list is subject to folding */
-                   _invlist_union(cp_list, PL_VertSpace, &cp_list);
+                   _invlist_union(cp_list, PL_XPosix_ptrs[classnum], &cp_list);
                    break;
                case ANYOF_NVERTWS:
                     _invlist_union_complement_2nd(cp_list,
-                                                    PL_VertSpace, &cp_list);
+                                                  PL_XPosix_ptrs[classnum],
+                                                  &cp_list);
                    break;
                case ANYOF_XDIGIT:
                     DO_POSIX(ret, namedclass, posixes,
-                                            PL_Posix_ptrs[classnum], PL_XPosixXDigit);
+                                            PL_Posix_ptrs[classnum], PL_XPosix_ptrs[classnum]);
                    break;
                case ANYOF_NXDIGIT:
                     DO_N_POSIX(ret, namedclass, posixes,
-                                            PL_Posix_ptrs[classnum], PL_XPosixXDigit);
+                                            PL_Posix_ptrs[classnum], PL_XPosix_ptrs[classnum]);
                    break;
                case ANYOF_UNIPROP: /* this is to handle \p and \P */
                    break;
diff --git a/sv.c b/sv.c
index 58a8ad5..e5bbb3d 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -13587,15 +13587,8 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
     /* Unicode inversion lists */
     PL_ASCII           = sv_dup_inc(proto_perl->IASCII, param);
     PL_Latin1          = sv_dup_inc(proto_perl->ILatin1, param);
-    PL_XPerlSpace      = sv_dup_inc(proto_perl->IXPerlSpace, param);
-    PL_XPosixBlank     = sv_dup_inc(proto_perl->IXPosixBlank, param);
     PL_L1Cased         = sv_dup_inc(proto_perl->IL1Cased, param);
 
-    PL_XPosixCntrl     = sv_dup_inc(proto_perl->IXPosixCntrl, param);
-    PL_XPosixSpace     = sv_dup_inc(proto_perl->IXPosixSpace, param);
-    PL_XPosixXDigit    = sv_dup_inc(proto_perl->IXPosixXDigit, param);
-    PL_VertSpace       = sv_dup_inc(proto_perl->IVertSpace, param);
-
     PL_NonL1NonFinalFold = sv_dup_inc(proto_perl->INonL1NonFinalFold, param);
     PL_HasMultiCharFold= sv_dup_inc(proto_perl->IHasMultiCharFold, param);
 
@@ -13606,6 +13599,7 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
     for (i = 0; i < POSIX_CC_COUNT; i++) {
         PL_Posix_ptrs[i] = sv_dup_inc(proto_perl->IPosix_ptrs[i], param);
         PL_L1Posix_ptrs[i] = sv_dup_inc(proto_perl->IL1Posix_ptrs[i], param);
+        PL_XPosix_ptrs[i] = sv_dup_inc(proto_perl->IXPosix_ptrs[i], param);
     }
     PL_utf8_mark       = sv_dup_inc(proto_perl->Iutf8_mark, param);
     PL_utf8_X_regular_begin    = sv_dup_inc(proto_perl->Iutf8_X_regular_begin, param);