This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Use xor to save a test
[perl5.git] / regcomp.c
index 9008ae7..35fd196 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -11459,7 +11459,11 @@ parseit:
                    if (UCHARAT(RExC_parse) == '^') {
                         RExC_parse++;
                         n--;
-                        value = value == 'p' ? 'P' : 'p'; /* toggle */
+                         /* toggle.  (The rhs xor gets the single bit that
+                          * differs between P and p; the other xor inverts just
+                          * that bit) */
+                         value ^= 'P' ^ 'p';
+
                         while (isSPACE(UCHARAT(RExC_parse))) {
                              RExC_parse++;
                              n--;