This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Collapse two switch cases
authorKarl Williamson <public@khwilliamson.com>
Mon, 31 Dec 2012 16:45:06 +0000 (09:45 -0700)
committerKarl Williamson <public@khwilliamson.com>
Mon, 31 Dec 2012 18:03:29 +0000 (11:03 -0700)
These two 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 c536adc..6d64c31 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -11907,26 +11907,18 @@ parseit:
                    break;
 
                case ANYOF_ASCII:
+               case ANYOF_NASCII:
 #ifdef HAS_ISASCII
                    if (LOC) {
                        ANYOF_CLASS_SET(ret, namedclass);
                    }
                     else
 #endif  /* Not isascii(); just use the hard-coded definition for it */
-                        _invlist_union(posixes, PL_ASCII, &posixes);
-                   break;
-               case ANYOF_NASCII:
-#ifdef HAS_ISASCII
-                   if (LOC) {
-                       ANYOF_CLASS_SET(ret, namedclass);
-                   }
-                    else {
-#endif
-                        _invlist_union_complement_2nd(posixes,
-                                                    PL_ASCII, &posixes);
-#ifdef HAS_ISASCII
-                    }
-#endif
+                        _invlist_union_maybe_complement_2nd(
+                                posixes,
+                                PL_ASCII,
+                                namedclass % 2, /* Complement if odd (NASCII) */
+                                &posixes);
                    break;
 
                case ANYOF_HORIZWS: