Commit 6832e04498 for perl
commit 6832e04498f65785365fc51fe664d12f72c20dd3
Author: Richard Leach <rich+perl@hyphen-dash-hyphen.info>
Date: Wed Nov 4 16:29:15 2026 +0000
pp_subst: force_it doesn't need to redo quite so much work
diff --git a/pp_hot.c b/pp_hot.c
index 1f419f8ca1..fcf7d77ae8 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -5399,8 +5399,7 @@ pp_match is just a simpler version of the above.
PP(pp_subst)
{
dTARG;
- PMOP *pm = cPMOP;
- PMOP *rpm = pm;
+ const PMOP *rpm = cPMOP;
char *s;
char *strend;
const char *c;
@@ -5412,7 +5411,7 @@ PP(pp_subst)
See "how taint works" above */
char *orig;
U8 r_flags;
- REGEXP *rx = PM_GETRE(pm);
+ REGEXP *rx = PM_GETRE(rpm);
regexp *prog = ReANY(rx);
STRLEN len;
int force_on_match = 0;
@@ -5427,7 +5426,7 @@ PP(pp_subst)
PERL_ASYNC_CHECK();
- if (pm->op_pmflags & PMf_CONST) {
+ if (rpm->op_pmflags & PMf_CONST) {
/* known replacement string */
dstr = *PL_stack_sp;
sp_offset++;
@@ -5484,23 +5483,13 @@ PP(pp_subst)
rxtainted = (
(SvTAINTED(TARG) ? SUBST_TAINT_STR : 0)
| (RXp_ISTAINTED(prog) ? SUBST_TAINT_PAT : 0)
- | ((pm->op_pmflags & PMf_RETAINT) ? SUBST_TAINT_RETAINT : 0)
+ | ((rpm->op_pmflags & PMf_RETAINT) ? SUBST_TAINT_RETAINT : 0)
| (( (once && !(rpm->op_pmflags & PMf_NONDESTRUCT))
|| (PL_op->op_private & OPpTRUEBOOL)) ? SUBST_TAINT_BOOLRET : 0));
TAINT_NOT;
}
- force_it:
- if (!pm || !orig)
- DIE(aTHX_ "panic: pp_subst, pm=%p, orig=%p", pm, orig);
-
- strend = orig + len;
- /* We can match twice at each position, once with zero-length,
- * second time with non-zero.
- * Don't handle utf8 specially; we can use length-in-bytes as an
- * upper bound on length-in-characters, and avoid the cpu-cost of
- * computing a tighter bound. */
- maxiters = 2 * len + 10;
+ PMOP *pm = cPMOP;
/* handle the empty pattern */
if (!RX_PRELEN(rx) && PL_curpm && !prog->mother_re) {
@@ -5531,6 +5520,18 @@ PP(pp_subst)
r_flags = REXEC_COPY_STR;
#endif
+ force_it:
+ if (!pm || !orig)
+ DIE(aTHX_ "panic: pp_subst, pm=%p, orig=%p", pm, orig);
+
+ strend = orig + len;
+ /* We can match twice at each position, once with zero-length,
+ * second time with non-zero.
+ * Don't handle utf8 specially; we can use length-in-bytes as an
+ * upper bound on length-in-characters, and avoid the cpu-cost of
+ * computing a tighter bound. */
+ maxiters = 2 * len + 10;
+
if (!CALLREGEXEC(rx, orig, strend, orig, 0, TARG, NULL, r_flags))
{
SV *ret = rpm->op_pmflags & PMf_NONDESTRUCT ? TARG : &PL_sv_no;