From: David Mitchell Date: Thu, 17 Feb 2011 14:17:13 +0000 (+0000) Subject: pp_subst: exit earlier after failed match X-Git-Tag: accepted/trunk/20130322.191538~5481 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5e79dfb9cd4496df40e823bec270c4bcde98db07;p=platform%2Fupstream%2Fperl.git pp_subst: exit earlier after failed match If the match fails, don't bother to execute some code that prepares the source and replacement strings for a substitution (e.g. matching UTF8-ness). (This is an enhancement to ff6e92e827a143094fdf3af374056b524759194b) --- diff --git a/pp_hot.c b/pp_hot.c index 8fb2f61..4fb5f01 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -2252,6 +2252,15 @@ PP(pp_subst) matched = CALLREGEXEC(rx, s, strend, orig, 0, TARG, NULL, r_flags | REXEC_CHECKED); + + if (!matched) { + ret_no: + SPAGAIN; + PUSHs(rpm->op_pmflags & PMf_NONDESTRUCT ? TARG : &PL_sv_no); + LEAVE_SCOPE(oldsave); + RETURN; + } + /* known replacement string? */ if (dstr) { if (SvTAINTED(dstr)) @@ -2261,7 +2270,7 @@ PP(pp_subst) * but only if it matched; see * http://www.nntp.perl.org/group/perl.perl5.porters/2010/04/msg158809.html */ - if (matched && DO_UTF8(dstr) && ! DO_UTF8(TARG)) { + if (DO_UTF8(dstr) && ! DO_UTF8(TARG)) { char * const orig_pvx = SvPVX(TARG); const STRLEN new_len = sv_utf8_upgrade_nomg(TARG); @@ -2294,14 +2303,6 @@ PP(pp_subst) doutf8 = FALSE; } - if (!matched) { - ret_no: - SPAGAIN; - PUSHs(rpm->op_pmflags & PMf_NONDESTRUCT ? TARG : &PL_sv_no); - LEAVE_SCOPE(oldsave); - RETURN; - } - /* can do inplace substitution? */ if (c #ifdef PERL_OLD_COPY_ON_WRITE