regcomp.c: Use xor to save a test
authorKarl Williamson <public@khwilliamson.com>
Thu, 27 Dec 2012 22:26:01 +0000 (15:26 -0700)
committerKarl Williamson <public@khwilliamson.com>
Fri, 28 Dec 2012 17:38:56 +0000 (10:38 -0700)
(Perhaps the C optimizer already figures this out.)

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--;