This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Combine some cases in a switch()
authorKarl Williamson <public@khwilliamson.com>
Sun, 16 Dec 2012 02:28:20 +0000 (19:28 -0700)
committerKarl Williamson <public@khwilliamson.com>
Sat, 22 Dec 2012 18:11:30 +0000 (11:11 -0700)
These cases differ only in the operand.  The logic is identical.

regcomp.c

index a891053..fbff672 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -12047,18 +12047,6 @@ parseit:
                         PL_Posix_ptrs[classnum], PL_Posix_ptrs[classnum], swash_property_names[classnum], listsv,
                         runtime_posix_matches_above_Unicode);
                    break;
-               case ANYOF_HORIZWS:
-                   /* 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.  It turns out that \h
-                    * is just a synonym for XPosixBlank */
-                   _invlist_union(cp_list, PL_XPosix_ptrs[_CC_BLANK], &cp_list);
-                   break;
-               case ANYOF_NHORIZWS:
-                    _invlist_union_complement_2nd(cp_list,
-                                                 PL_XPosix_ptrs[_CC_BLANK], &cp_list);
-                   break;
                case ANYOF_LOWER:
                case ANYOF_NLOWER:
                case ANYOF_UPPER:
@@ -12092,20 +12080,33 @@ parseit:
                    }
                    break;
                }
+               case ANYOF_HORIZWS:
+                    /* 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
+                     * themselves, as cp_list is subject to folding.
+                     *
+                     * It turns out that \h is just a synonym for XPosixBlank */
+                    classnum = _CC_BLANK;
+                   /* FALL THROUGH */
+
                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_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);
                    break;
+
                case ANYOF_UNIPROP: /* this is to handle \p and \P */
                    break;
+
                default:
                    vFAIL("Invalid [::] class");
                    break;