This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Collapse switch cases
authorKarl Williamson <public@khwilliamson.com>
Mon, 31 Dec 2012 17:00:55 +0000 (10:00 -0700)
committerKarl Williamson <public@khwilliamson.com>
Mon, 31 Dec 2012 18:03:29 +0000 (11:03 -0700)
These cases differ only in that the union is of the complement in one of
them.  There is a function that provides both possibilities.

regcomp.c

index 6d64c31..d88dcb9 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -11920,8 +11920,8 @@ parseit:
                                 namedclass % 2, /* Complement if odd (NASCII) */
                                 &posixes);
                    break;
-
                case ANYOF_HORIZWS:
+               case ANYOF_NHORIZWS:
                     /* For these, we use the cp_list, as neither /d nor /l make
                      * a difference in what these match.  There would be
                      * problems if these characters had folds other than
@@ -11930,19 +11930,14 @@ parseit:
                      * It turns out that \h is just a synonym for XPosixBlank */
                     classnum = _CC_BLANK;
                    /* FALL THROUGH */
-
                case ANYOF_VERTWS:
-                   _invlist_union(cp_list, PL_XPosix_ptrs[classnum], &cp_list);
-                   break;
-
-               case ANYOF_NHORIZWS:
-                    classnum = _CC_BLANK;
-                   /* FALL THROUGH */
-
                case ANYOF_NVERTWS:
-                    _invlist_union_complement_2nd(cp_list,
-                                                  PL_XPosix_ptrs[classnum],
-                                                  &cp_list);
+                   _invlist_union_maybe_complement_2nd(
+                                cp_list,
+                                PL_XPosix_ptrs[classnum],
+                                namedclass % 2,  /* Complement if odd
+                                                    (NHORIZWS, NVERTWS) */
+                                &cp_list);
                    break;
 
                case ANYOF_UNIPROP: /* this is to handle \p and \P */