Change 32755 by [EMAIL PROTECTED] on 2007/12/28 22:19:00
Eliminate precomp from struct regexp. Store the offset of precomp from
wrapped in pre_prefix, a 4 bit value. (Maybe only for now) reduce
seen_evals from I32 to 28 bits. Will anyone have more than 268435456
eval groups in a regexp?
Affected files ...
... //depot/perl/regcomp.c#624 edit
... //depot/perl/regexp.h#113 edit
Differences ...
==== //depot/perl/regcomp.c#624 (text) ====
Index: perl/regcomp.c
--- perl/regcomp.c#623~32754~ 2007-12-28 14:01:30.000000000 -0800
+++ perl/regcomp.c 2007-12-28 14:19:00.000000000 -0800
@@ -4319,7 +4319,8 @@
*p++ = ':';
Copy(RExC_precomp, p, RX_PRELEN(r), char);
- RX_PRECOMP(r) = p;
+ assert ((r->wrapped - p) < 16);
+ r->pre_prefix = p - r->wrapped;
p += RX_PRELEN(r);
if (has_runon)
*p++ = '\n';
@@ -9371,7 +9372,6 @@
dVAR;
regexp *ret;
I32 npar;
- U32 precomp_offset;
if (!r)
return (REGEXP *)NULL;
@@ -9420,10 +9420,7 @@
}
}
- precomp_offset = RX_PRECOMP(ret) - ret->wrapped;
-
ret->wrapped = SAVEPVN(ret->wrapped, ret->wraplen+1);
- RX_PRECOMP(ret) = ret->wrapped + precomp_offset;
ret->paren_names = hv_dup_inc(ret->paren_names, param);
if (ret->pprivate)
==== //depot/perl/regexp.h#113 (text) ====
Index: perl/regexp.h
--- perl/regexp.h#112~32753~ 2007-12-28 13:25:50.000000000 -0800
+++ perl/regexp.h 2007-12-28 14:19:00.000000000 -0800
@@ -99,11 +99,11 @@
/* Information about the match that isn't often used */
I32 prelen; /* length of precomp */
- const char *precomp; /* pre-compilation regular expression */
/* wrapped can't be const char*, as it is returned by sv_2pv_flags */
char *wrapped; /* wrapped version of the pattern */
I32 wraplen; /* length of wrapped */
- I32 seen_evals; /* number of eval groups in the pattern - for
security checks */
+ unsigned pre_prefix:4; /* offset from wrapped to the start of precomp
*/
+ unsigned seen_evals:28; /* number of eval groups in the pattern - for
security checks */
HV *paren_names; /* Optional hash of paren names */
/* Refcount of this regexp */
@@ -354,7 +354,7 @@
: RX_MATCH_COPIED_off(prog))
/* For source compatibility. We used to store these explicitly. */
-#define RX_PRECOMP(prog) ((prog)->precomp)
+#define RX_PRECOMP(prog) ((prog)->wrapped + (prog)->pre_prefix)
#define RX_PRELEN(prog) ((prog)->prelen)
#endif /* PLUGGABLE_RE_EXTENSION */
End of Patch.