This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Reorder two if-elses
authorKarl Williamson <public@khwilliamson.com>
Tue, 18 Dec 2012 20:58:00 +0000 (13:58 -0700)
committerKarl Williamson <public@khwilliamson.com>
Sat, 22 Dec 2012 18:11:32 +0000 (11:11 -0700)
It is generally easier to understand an
    if () { few statements } else { many statements}
than the other way around.

regcomp.c

index 59e4710..b58c8b2 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -11695,7 +11695,15 @@ parseit:
                case ANYOF_PSXSPC:
                case ANYOF_SPACE:
                case ANYOF_XDIGIT:
-                    if (LOC) {
+                    if (! LOC) {
+                        /* For non-locale, just add it to any existing list */
+                        _invlist_union(posixes,
+                                       (AT_LEAST_ASCII_RESTRICTED)
+                                           ? ascii_source
+                                           : PL_XPosix_ptrs[classnum],
+                                       &posixes);
+                    }
+                    else {  /* Locale */
                         SV* scratch_list = NULL;
 
                         /* For above Latin1 code points, we use the full
@@ -11733,14 +11741,6 @@ parseit:
                         }
 #endif
                     }
-                    else {
-                        /* For non-locale, just add it to any existing list */
-                        _invlist_union(posixes,
-                                       (AT_LEAST_ASCII_RESTRICTED)
-                                           ? ascii_source
-                                           : PL_XPosix_ptrs[classnum],
-                                       &posixes);
-                    }
                    break;
 
                case ANYOF_NDIGIT:
@@ -11808,7 +11808,20 @@ parseit:
                case ANYOF_NPSXSPC:
                case ANYOF_NSPACE:
                case ANYOF_NXDIGIT:
-                    if (LOC) {
+                    if (! LOC) {
+                        _invlist_union_complement_2nd(
+                                                posixes,
+                                                (AT_LEAST_ASCII_RESTRICTED)
+                                                    ? ascii_source
+                                                    : PL_XPosix_ptrs[classnum],
+                                                &posixes);
+                        /* Under /d, everything in the upper half of the Latin1
+                         * range matches this complement */
+                        if (DEPENDS_SEMANTICS) {
+                            ANYOF_FLAGS(ret) |= ANYOF_NON_UTF8_LATIN1_ALL;
+                        }
+                    }
+                    else {  /* Locale */
                         SV* scratch_list = NULL;
                         _invlist_subtract(PL_AboveLatin1,
                                           PL_XPosix_ptrs[classnum],
@@ -11837,19 +11850,6 @@ parseit:
                         }
 #endif
                     }
-                    else {
-                        _invlist_union_complement_2nd(
-                                                posixes,
-                                                (AT_LEAST_ASCII_RESTRICTED)
-                                                    ? ascii_source
-                                                    : PL_XPosix_ptrs[classnum],
-                                                &posixes);
-                        /* Under /d, everything in the upper half of the Latin1
-                         * range matches this complement */
-                        if (DEPENDS_SEMANTICS) {
-                            ANYOF_FLAGS(ret) |= ANYOF_NON_UTF8_LATIN1_ALL;
-                        }
-                    }
                    break;
 
                case ANYOF_ASCII: