summaryrefslogtreecommitdiff
path: root/regcomp.h
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2013-11-25 20:12:33 -0700
committerKarl Williamson <public@khwilliamson.com>2013-12-31 08:27:21 -0700
commit5dbb0c086b3025f9e48420fe3db4747e977ecfd6 (patch)
treefdd53dbb8433d6816bc177de918015e4a1b6de49 /regcomp.h
parente9b08962fbb05ece388fd5076686a7edfd6dbe3b (diff)
downloadperl-5dbb0c086b3025f9e48420fe3db4747e977ecfd6.tar.gz
Re-order some flag bits to avoid potential branches
The ANYOF_INVERT flag is used in every single pattern match of [bracketed character classes]. With backtracking, this can be a huge number. All the other flags' uses pale by comparison. I noticed that by making it the lowest bit, we don't have to use CBOOL, as the only possibilities are 0 and 1. cBOOL hopefully will be optimized away, but not always. This commit reorders some of the flag bits to make this one the lowest, and adds a compile check to make sure it isn't inadvertently changed.
Diffstat (limited to 'regcomp.h')
-rw-r--r--regcomp.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/regcomp.h b/regcomp.h
index 9b0d7dadba..21a418cb4c 100644
--- a/regcomp.h
+++ b/regcomp.h
@@ -327,15 +327,16 @@ struct regnode_ssc {
* used in synthetic start class (SSC) nodes, so could be shared should new
* flags be needed for SSCs. */
-#define ANYOF_LOCALE 0x01 /* /l modifier */
+#define ANYOF_LOCALE 0x02 /* /l modifier */
/* The fold is calculated and stored in the bitmap where possible at compile
* time. However under locale, the actual folding varies depending on
* what the locale is at the time of execution, so it has to be deferred until
* then */
-#define ANYOF_LOC_FOLD 0x02
+#define ANYOF_LOC_FOLD 0x04
-#define ANYOF_INVERT 0x04
+/* regexec.c is expecting this to be in the low bit */
+#define ANYOF_INVERT 0x01
/* For the SSC node only, which cannot be inverted, so is shared with that bit.
* This means "Does this SSC match an empty string?" This is used only during