This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Use calculated value instead of hard-coded
authorKarl Williamson <public@khwilliamson.com>
Thu, 13 Dec 2012 15:41:02 +0000 (08:41 -0700)
committerKarl Williamson <public@khwilliamson.com>
Sat, 22 Dec 2012 18:11:28 +0000 (11:11 -0700)
After this commit, these two cases in the switch are identical, and can
be collapsed.  This also reverses the sense of the 'if', to avoid a
negative, which is harder to read.

regcomp.c

index 459105e..9ae03c7 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -12084,14 +12084,14 @@ parseit:
                        Xname = swash_property_names[classnum];
                         swash = PL_utf8_swash_ptrs[classnum];
                    }
-                   if (namedclass == ANYOF_LOWER) {
-                       DO_POSIX_LATIN1_ONLY_KNOWN(ret, namedclass, posixes,
-                                    ascii_source, swash, l1_source, Xname, listsv);
+                   if (namedclass % 2) {   /* If odd, is the complemented version */
+                       DO_N_POSIX_LATIN1_ONLY_KNOWN(ret, namedclass,
+                        posixes, ascii_source, l1_source, Xname, listsv,
+                        runtime_posix_matches_above_Unicode);
                    }
                    else {
-                       DO_N_POSIX_LATIN1_ONLY_KNOWN(ret, namedclass,
-                            posixes, ascii_source, l1_source, Xname, listsv,
-                            runtime_posix_matches_above_Unicode);
+                       DO_POSIX_LATIN1_ONLY_KNOWN(ret, namedclass, posixes,
+                                    ascii_source, swash, l1_source, Xname, listsv);
                    }
                    break;
                }
@@ -12131,15 +12131,15 @@ parseit:
                        Xname = swash_property_names[classnum];
                         swash = PL_utf8_swash_ptrs[classnum];
                    }
-                   if (namedclass == ANYOF_UPPER) {
-                       DO_POSIX_LATIN1_ONLY_KNOWN(ret, namedclass, posixes,
-                                    ascii_source, swash, l1_source, Xname, listsv);
-                   }
-                   else {
+                   if (namedclass % 2) {   /* If odd, is the complemented version */
                        DO_N_POSIX_LATIN1_ONLY_KNOWN(ret, namedclass,
                         posixes, ascii_source, l1_source, Xname, listsv,
                         runtime_posix_matches_above_Unicode);
                    }
+                   else {
+                       DO_POSIX_LATIN1_ONLY_KNOWN(ret, namedclass, posixes,
+                                    ascii_source, swash, l1_source, Xname, listsv);
+                   }
                    break;
                }
                case ANYOF_VERTWS: