From 1497789321a3812581136bb80750207bffc72afc Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Sun, 18 Nov 2001 18:59:28 +0000 Subject: Retract #13048: that introduced a malloc() (through savepvn()) to *every* m//, which killed the performance quite badly. p4raw-id: //depot/perl@13079 --- pp_hot.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'pp_hot.c') diff --git a/pp_hot.c b/pp_hot.c index 77e070fbb7..f1274a63e4 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -1264,7 +1264,9 @@ PP(pp_match) } } } - r_flags |= REXEC_COPY_STR; + if ((!global && rx->nparens) + || SvTEMP(TARG) || PL_sawampersand) + r_flags |= REXEC_COPY_STR; if (SvSCREAM(TARG)) r_flags |= REXEC_SCREAM; @@ -1289,7 +1291,7 @@ play_it_again: if (!s) goto nope; if ( (rx->reganch & ROPT_CHECK_ALL) - && !((rx->reganch & ROPT_SEOL_SEEN) && PL_multiline) + && !PL_sawampersand && ((rx->reganch & ROPT_NOSCAN) || !((rx->reganch & RE_INTUIT_TAIL) && (r_flags & REXEC_SCREAM))) @@ -1406,12 +1408,19 @@ yup: /* Confirmed by INTUIT */ rx->sublen = strend - truebase; goto gotcha; } + if (PL_sawampersand) { + I32 off; - rx->sublen = strend - t; - rx->subbeg = savepvn(t, rx->sublen); - RX_MATCH_COPIED_on(rx); - rx->startp[0] = s - truebase; - rx->endp[0] = s - truebase + rx->minlen; + rx->subbeg = savepvn(t, strend - t); + rx->sublen = strend - t; + RX_MATCH_COPIED_on(rx); + off = rx->startp[0] = s - t; + rx->endp[0] = off + rx->minlen; + } + else { /* startp/endp are used by @- @+. */ + rx->startp[0] = s - truebase; + rx->endp[0] = s - truebase + rx->minlen; + } rx->nparens = rx->lastparen = 0; /* used by @- and @+ */ LEAVE_SCOPE(oldsave); RETPUSHYES; -- cgit v1.2.1