regcomp.c: Refactor 'if' statement
authorKarl Williamson <public@khwilliamson.com>
Thu, 19 Dec 2013 05:53:46 +0000 (22:53 -0700)
committerKarl Williamson <public@khwilliamson.com>
Tue, 31 Dec 2013 15:27:22 +0000 (08:27 -0700)
This refactoring makes it clear that within a (?[]), we don't try to
optimize the [] part.  This is for clarity for the future only, as
currently the only changed behavior is if this is being compiled with /l
rules, and (?[]) generates a syntax error under /l.

regcomp.c

index 5c3260a..5b10edd 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -13953,8 +13953,9 @@ parseit:
     /* If the character class contains only a single element, it may be
      * optimizable into another node type which is smaller and runs faster.
      * Check if this is the case for this class */
-    if ((element_count == 1 && ! ret_invlist)
-        || UNLIKELY(posixl_matches_all))
+    if (! ret_invlist   /* Can't optimize if returning the constructed
+                           inversion list */
+        && (UNLIKELY(posixl_matches_all) || element_count == 1))
     {
         U8 op = END;
         U8 arg = 0;