summaryrefslogtreecommitdiff
path: root/pp_hot.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-11-18 18:59:28 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-11-18 18:59:28 +0000
commit1497789321a3812581136bb80750207bffc72afc (patch)
tree13b6f42b71dab4c4cada0f6e081079706aa1c11f /pp_hot.c
parent77c8cf410d66a85c2c49a1156db76d3221824e47 (diff)
downloadperl-1497789321a3812581136bb80750207bffc72afc.tar.gz
Retract #13048: that introduced a malloc() (through savepvn())
to *every* m//, which killed the performance quite badly. p4raw-id: //depot/perl@13079
Diffstat (limited to 'pp_hot.c')
-rw-r--r--pp_hot.c23
1 files changed, 16 insertions, 7 deletions
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;