This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Simplify
authorKarl Williamson <khw@cpan.org>
Fri, 3 Apr 2020 17:46:20 +0000 (11:46 -0600)
committerKarl Williamson <khw@cpan.org>
Fri, 16 Oct 2020 13:01:41 +0000 (07:01 -0600)
This was a case statement of every type of EXACTish node.  Instead,
there is a simple way to see if something is EXACTish.

regcomp.c

index 66ac07e..43f6b88 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -20761,30 +20761,15 @@ S_regtail_study(pTHX_ RExC_state_t *pRExC_state, regnode_offset p,
        }
 #endif
         if ( exact ) {
-            switch (OP(REGNODE_p(scan))) {
-                case LEXACT:
-                case EXACT:
-                case LEXACT_REQ8:
-                case EXACT_REQ8:
-                case EXACTL:
-                case EXACTF:
-                case EXACTFU_S_EDGE:
-                case EXACTFAA_NO_TRIE:
-                case EXACTFAA:
-                case EXACTFU:
-                case EXACTFU_REQ8:
-                case EXACTFLU8:
-                case EXACTFUP:
-                case EXACTFL:
-                        if( exact == PSEUDO )
-                            exact= OP(REGNODE_p(scan));
-                        else if ( exact != OP(REGNODE_p(scan)) )
-                            exact= 0;
-                case NOTHING:
-                    break;
-                default:
+            if (PL_regkind[OP(REGNODE_p(scan))] == EXACT) {
+                if (exact == PSEUDO )
+                    exact= OP(REGNODE_p(scan));
+                else if (exact != OP(REGNODE_p(scan)) )
                     exact= 0;
             }
+            else if (OP(REGNODE_p(scan)) != NOTHING) {
+                exact= 0;
+            }
         }
         DEBUG_PARSE_r({
             DEBUG_PARSE_MSG((scan==p ? "tsdy" : ""));