summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regcomp.c18
-rw-r--r--regcomp.h10
2 files changed, 14 insertions, 14 deletions
diff --git a/regcomp.c b/regcomp.c
index bfcbd6b5fe..5513a0a592 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -8714,6 +8714,13 @@ Perl_regdupe(pTHX_ const regexp *r, CLONE_PARAMS *param)
d->data[i] = (void*)OpREFCNT_inc((OP*)ri->data->data[i]);
OP_REFCNT_UNLOCK;
break;
+ case 'T':
+ /* Trie stclasses are readonly and can thus be shared
+ * without duplication. We free the stclass in pregfree
+ * when the corresponding reg_ac_data struct is freed.
+ */
+ reti->regstclass= ri->regstclass;
+ /* Fall through */
case 't':
OP_REFCNT_LOCK;
((reg_trie_data*)ri->data->data[i])->refcount++;
@@ -8722,17 +8729,6 @@ Perl_regdupe(pTHX_ const regexp *r, CLONE_PARAMS *param)
case 'n':
d->data[i] = ri->data->data[i];
break;
- case 'T':
- d->data[i] = ri->data->data[i];
- OP_REFCNT_LOCK;
- ((reg_ac_data*)d->data[i])->refcount++;
- OP_REFCNT_UNLOCK;
- /* Trie stclasses are readonly and can thus be shared
- * without duplication. We free the stclass in pregfree
- * when the corresponding reg_ac_data struct is freed.
- */
- reti->regstclass= ri->regstclass;
- break;
default:
Perl_croak(aTHX_ "panic: re_dup unknown data code '%c'", ri->data->what[i]);
}
diff --git a/regcomp.h b/regcomp.h
index e8fd39ff02..f591726800 100644
--- a/regcomp.h
+++ b/regcomp.h
@@ -512,8 +512,11 @@ typedef struct _reg_trie_trans reg_trie_trans;
/* anything in here that needs to be freed later
- should be dealt with in pregfree */
+ should be dealt with in pregfree.
+ refcount is first in both this and _reg_ac_data to allow a space
+ optimisation in Perl_regdupe. */
struct _reg_trie_data {
+ U32 refcount; /* number of times this trie is referenced */
U16 uniquecharcount; /* unique chars in trie (width of trans table) */
U32 lasttrans; /* last valid transition element */
U16 *charmap; /* byte to charid lookup array */
@@ -521,7 +524,6 @@ struct _reg_trie_data {
reg_trie_state *states; /* state data */
reg_trie_trans *trans; /* array of transition elements */
char *bitmap; /* stclass bitmap */
- U32 refcount; /* number of times this trie is referenced */
U32 startstate; /* initial state - used for common prefix optimisation */
STRLEN minlen; /* minimum length of words in trie - build/opt only? */
STRLEN maxlen; /* maximum length of words in trie - build/opt only? */
@@ -541,11 +543,13 @@ struct _reg_trie_data {
};
typedef struct _reg_trie_data reg_trie_data;
+/* refcount is first in both this and _reg_trie_data to allow a space
+ optimisation in Perl_regdupe. */
struct _reg_ac_data {
+ U32 refcount;
U32 *fail;
reg_trie_state *states;
reg_trie_data *trie;
- U32 refcount;
};
typedef struct _reg_ac_data reg_ac_data;