This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Use existing function to do task
authorKarl Williamson <khw@cpan.org>
Thu, 25 Jan 2018 20:20:24 +0000 (13:20 -0700)
committerKarl Williamson <khw@cpan.org>
Thu, 25 Jan 2018 20:53:10 +0000 (13:53 -0700)
The function does it better than this code, which looked too deeply into
the internals, and got it wrong sometimes, because it didn't look at the
state of the inversion.  The consequences are not a bug, but potentially
forgoing an optimization, or needlessly looking for an optimization that
will turn out to not be there.

regcomp.c

index 3447fdb..c4ad1d1 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -18100,8 +18100,6 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
         invlist_iterfinish(cp_list);
 
         if (op == END) {
-            const UV cp_list_len = _invlist_len(cp_list);
-            const UV* cp_list_array = invlist_array(cp_list);
 
             /* Here, didn't find an optimization.  See if this matches any of
              * the POSIX classes.  First try ASCII */
@@ -18114,7 +18112,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
                 op = NASCII;
                 *flagp |= HASWIDTH|SIMPLE;
             }
-            else if (cp_list_array[cp_list_len-1] >= 0x2029) {
+            else if (invlist_highest(cp_list) >= 0x2029) {
 
                 /* Then try the other POSIX classes.  The POSIXA ones are about
                  * the same speed as ANYOF ops, but the ones that have