summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-11-26 23:01:46 +0000
committerNicholas Clark <nick@ccl4.org>2006-11-26 23:01:46 +0000
commit3251b6533b8ccfabab55365b302970011d85066a (patch)
tree13a0462c78f9010f12c30f1c8050d26de71e2ed3
parent23eab42ccdcdf01b414e4c1728d8f919b2705614 (diff)
downloadperl-3251b6533b8ccfabab55365b302970011d85066a.tar.gz
Swap _reg_ac_data.trie to U32 offset into the regdata array, as
preliminary to moving _reg_trie_data.widecharmap out too. p4raw-id: //depot/perl@29392
-rw-r--r--regcomp.c17
-rw-r--r--regcomp.h2
-rw-r--r--regexec.c3
3 files changed, 10 insertions, 12 deletions
diff --git a/regcomp.c b/regcomp.c
index 5513a0a592..c5c91498be 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -2060,7 +2060,8 @@ S_make_trie_failtable(pTHX_ RExC_state_t *pRExC_state, regnode *source, regnode
try 'g' and succeed, prodceding to match 'cdgu'.
*/
/* add a fail transition */
- reg_trie_data *trie=(reg_trie_data *)RExC_rxi->data->data[ARG(source)];
+ const U32 trie_offset = ARG(source);
+ reg_trie_data *trie=(reg_trie_data *)RExC_rxi->data->data[trie_offset];
U32 *q;
const U32 ucharcount = trie->uniquecharcount;
const U32 numstates = trie->statecount;
@@ -2081,7 +2082,7 @@ S_make_trie_failtable(pTHX_ RExC_state_t *pRExC_state, regnode *source, regnode
ARG_SET( stclass, data_slot );
aho = PerlMemShared_calloc( 1, sizeof(reg_ac_data) );
RExC_rxi->data->data[ data_slot ] = (void*)aho;
- aho->trie=trie;
+ aho->trie=trie_offset;
aho->states=(reg_trie_state *)PerlMemShared_malloc( numstates * sizeof(reg_trie_state) );
Copy( trie->states, aho->states, numstates, reg_trie_state );
Newxz( q, numstates, U32);
@@ -8228,9 +8229,8 @@ Perl_regprop(pTHX_ const regexp *prog, SV *sv, const regnode *o)
const reg_ac_data * const ac = IS_TRIE_AC(op) ?
(reg_ac_data *)progi->data->data[n] :
NULL;
- const reg_trie_data * const trie = !IS_TRIE_AC(op) ?
- (reg_trie_data*)progi->data->data[n] :
- ac->trie;
+ const reg_trie_data * const trie
+ = (reg_trie_data*)progi->data->data[!IS_TRIE_AC(op) ? n : ac->trie];
Perl_sv_catpvf(aTHX_ sv, "-%s",reg_name[o->flags]);
DEBUG_TRIE_COMPILE_r(
@@ -8559,8 +8559,6 @@ Perl_pregfree(pTHX_ struct regexp *r)
if ( !refcount ) {
PerlMemShared_free(aho->states);
PerlMemShared_free(aho->fail);
- aho->trie=NULL; /* not necessary to free this as it is
- handled by the 't' case */
/* do this last!!!! */
PerlMemShared_free(ri->data->data[n]);
PerlMemShared_free(ri->regstclass);
@@ -9092,9 +9090,8 @@ S_dumpuntil(pTHX_ const regexp *r, const regnode *start, const regnode *node,
const reg_ac_data * const ac = op>=AHOCORASICK ?
(reg_ac_data *)ri->data->data[n] :
NULL;
- const reg_trie_data * const trie = op<AHOCORASICK ?
- (reg_trie_data*)ri->data->data[n] :
- ac->trie;
+ const reg_trie_data * const trie =
+ (reg_trie_data*)ri->data->data[op<AHOCORASICK ? n : ac->trie];
const regnode *nextbranch= NULL;
I32 word_idx;
sv_setpvn(sv, "", 0);
diff --git a/regcomp.h b/regcomp.h
index f591726800..4ae26594f0 100644
--- a/regcomp.h
+++ b/regcomp.h
@@ -549,7 +549,7 @@ struct _reg_ac_data {
U32 refcount;
U32 *fail;
reg_trie_state *states;
- reg_trie_data *trie;
+ U32 trie;
};
typedef struct _reg_ac_data reg_ac_data;
diff --git a/regexec.c b/regexec.c
index fe1c0f39c0..b184db1fb7 100644
--- a/regexec.c
+++ b/regexec.c
@@ -1419,7 +1419,8 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
/* what trie are we using right now */
reg_ac_data *aho
= (reg_ac_data*)progi->data->data[ ARG( c ) ];
- reg_trie_data *trie=aho->trie;
+ reg_trie_data *trie
+ = (reg_trie_data*)progi->data->data[ aho->trie ];
const char *last_start = strend - trie->minlen;
#ifdef DEBUGGING