This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add note to debugging output if regex already compiled
authorKarl Williamson <khw@cpan.org>
Thu, 26 Sep 2019 19:14:14 +0000 (13:14 -0600)
committerKarl Williamson <khw@cpan.org>
Fri, 27 Sep 2019 17:20:34 +0000 (11:20 -0600)
Prior to this commit, the debugging output says "Compiling REx foo".
But there was no indication that it was skipped due to the pattern
already being compiled; so that was confusing to people, and was a Stack
Overflow question of what is going on.  Now there's an extra message
that the recompilation is skipped.

regcomp.c

index b389f9e..c770f9d 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -7584,6 +7584,12 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
         && memEQ(RX_PRECOMP(old_re), exp, plen)
        && !runtime_code /* with runtime code, always recompile */ )
     {
+        DEBUG_COMPILE_r({
+            SV *dsv= sv_newmortal();
+            RE_PV_QUOTED_DECL(s, RExC_utf8, dsv, exp, plen, PL_dump_re_max_len);
+            Perl_re_printf( aTHX_  "%sSkipping recompilation of unchanged REx%s %s\n",
+                          PL_colors[4], PL_colors[5], s);
+        });
         return old_re;
     }