This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Use better method for setting debug offsets
authorKarl Williamson <khw@cpan.org>
Wed, 21 Nov 2018 04:21:44 +0000 (21:21 -0700)
committerKarl Williamson <khw@cpan.org>
Tue, 27 Nov 2018 04:32:25 +0000 (21:32 -0700)
This was changing the parse pointer around some code and restoring it
afterwards.  The purpose must have been to get the debug offsets
correct.  But there is a better way to do that, which doesn't take up
cycles on a non-Debugging build, and that is to set the offsets
directly.

regcomp.c

index 1d9ff63..ee67f5a 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -18098,7 +18098,6 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
 
     if (optimizable) {
         int posix_class = -1;   /* Illegal value */
-        const char * cur_parse= RExC_parse;
         U8 ANYOFM_mask = 0xFF;
         U32 anode_arg = 0;
         UV start, end;
@@ -18364,15 +18363,13 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
         }
 
         if (op != END) {
-            RExC_parse = (char *)orig_parse;
-
             if (regarglen[op]) {
                 ret = reganode(pRExC_state, op, anode_arg);
             } else {
                 ret = reg_node(pRExC_state, op);
             }
-
-            RExC_parse = (char *)cur_parse;
+            Set_Node_Offset_Length(REGNODE_p(ret), orig_parse - RExC_start,
+                                                   RExC_parse - orig_parse);;
 
             if (PL_regkind[op] == EXACT) {
                 alloc_maybe_populate_EXACT(pRExC_state, ret, flagp, 0, value,