From: Nicholas Clark Date: Sun, 26 Nov 2006 23:01:46 +0000 (+0000) Subject: Swap _reg_ac_data.trie to U32 offset into the regdata array, as X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3251b6533b8ccfabab55365b302970011d85066a;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/regcomp.c b/regcomp.c index 5513a0a..c5c9149 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 = opdata->data[n] : - ac->trie; + const reg_trie_data * const trie = + (reg_trie_data*)ri->data->data[optrie]; const regnode *nextbranch= NULL; I32 word_idx; sv_setpvn(sv, "", 0); diff --git a/regcomp.h b/regcomp.h index f591726..4ae2659 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 fe1c0f3..b184db1 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