Change 13079 by jhi@alpha on 2001/11/18 18:59:28
Retract #13048: that introduced a malloc() (through savepvn())
to *every* m//, which killed the performance quite badly.
Affected files ...
.... //depot/perl/pp_hot.c#262 edit
.... //depot/perl/regcomp.c#251 edit
.... //depot/perl/regcomp.h#56 edit
.... //depot/perl/regexp.h#28 edit
.... //depot/perl/t/op/re_tests#67 edit
Differences ...
==== //depot/perl/pp_hot.c#262 (text) ====
Index: perl/pp_hot.c
--- perl/pp_hot.c.~1~ Sun Nov 18 12:15:05 2001
+++ perl/pp_hot.c Sun Nov 18 12:15:05 2001
@@ -1264,7 +1264,9 @@
}
}
}
- 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 @@
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 @@
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;
==== //depot/perl/regcomp.c#251 (text) ====
Index: perl/regcomp.c
--- perl/regcomp.c.~1~ Sun Nov 18 12:15:05 2001
+++ perl/regcomp.c Sun Nov 18 12:15:05 2001
@@ -2016,8 +2016,6 @@
r->reganch |= ROPT_EVAL_SEEN;
if (RExC_seen & REG_SEEN_CANY)
r->reganch |= ROPT_CANY_SEEN;
- if (RExC_seen & REG_SEEN_SEOL)
- r->reganch |= ROPT_SEOL_SEEN;
Newz(1002, r->startp, RExC_npar, I32);
Newz(1002, r->endp, RExC_npar, I32);
PL_regdata = r->data; /* for regprop() */
@@ -2796,7 +2794,6 @@
break;
case 'Z':
ret = reg_node(pRExC_state, SEOL);
- RExC_seen |= REG_SEEN_SEOL;
*flagp |= SIMPLE;
nextchar(pRExC_state);
break;
==== //depot/perl/regcomp.h#56 (text) ====
Index: perl/regcomp.h
--- perl/regcomp.h.~1~ Sun Nov 18 12:15:05 2001
+++ perl/regcomp.h Sun Nov 18 12:15:05 2001
@@ -311,7 +311,6 @@
#define REG_SEEN_EVAL 8
#define REG_SEEN_CANY 16
#define REG_SEEN_SANY REG_SEEN_CANY /* src bckwrd cmpt */
-#define REG_SEEN_SEOL 32
START_EXTERN_C
==== //depot/perl/regexp.h#28 (text) ====
Index: perl/regexp.h
--- perl/regexp.h.~1~ Sun Nov 18 12:15:05 2001
+++ perl/regexp.h Sun Nov 18 12:15:05 2001
@@ -58,7 +58,6 @@
#define ROPT_EVAL_SEEN 0x00400
#define ROPT_CANY_SEEN 0x00800
#define ROPT_SANY_SEEN ROPT_CANY_SEEN /* src bckwrd cmpt */
-#define ROPT_SEOL_SEEN 0x01000
/* 0xf800 of reganch is used by PMf_COMPILETIME */
==== //depot/perl/t/op/re_tests#67 (text) ====
Index: perl/t/op/re_tests
--- perl/t/op/re_tests.~1~ Sun Nov 18 12:15:05 2001
+++ perl/t/op/re_tests Sun Nov 18 12:15:05 2001
@@ -537,7 +537,7 @@
a\Z b\na y $-[0] 2
a\z b\na y $-[0] 2
a$ b\na y $-[0] 2
-'a\Z'm a\nb\n n - -
+'a\Z'm a\nb\n bn - -
'a\z'm a\nb\n n - -
'a$'m a\nb\n y $-[0] 0
'a\Z'm b\na\n y $-[0] 2
@@ -555,7 +555,7 @@
aa\Z b\naa y $-[0] 2
aa\z b\naa y $-[0] 2
aa$ b\naa y $-[0] 2
-'aa\Z'm aa\nb\n n - -
+'aa\Z'm aa\nb\n bn - -
'aa\z'm aa\nb\n n - -
'aa$'m aa\nb\n y $-[0] 0
'aa\Z'm b\naa\n y $-[0] 2
@@ -609,7 +609,7 @@
ab\Z b\nab y $-[0] 2
ab\z b\nab y $-[0] 2
ab$ b\nab y $-[0] 2
-'ab\Z'm ab\nb\n n - -
+'ab\Z'm ab\nb\n bn - -
'ab\z'm ab\nb\n n - -
'ab$'m ab\nb\n y $-[0] 0
'ab\Z'm b\nab\n y $-[0] 2
@@ -663,7 +663,7 @@
abb\Z b\nabb y $-[0] 2
abb\z b\nabb y $-[0] 2
abb$ b\nabb y $-[0] 2
-'abb\Z'm abb\nb\n n - -
+'abb\Z'm abb\nb\n bn - -
'abb\z'm abb\nb\n n - -
'abb$'m abb\nb\n y $-[0] 0
'abb\Z'm b\nabb\n y $-[0] 2
End of Patch.