From cac0218b84f9ae47a2369c80f167b508534e0351 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Thu, 26 Sep 2019 13:14:14 -0600 Subject: [PATCH] Add note to debugging output if regex already compiled 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/regcomp.c b/regcomp.c index b389f9e..c770f9d 100644 --- 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; } -- 1.8.3.1