use original (more efficient) sub allocator
This commit is contained in:
24
pike.c
24
pike.c
@@ -451,14 +451,11 @@ int re_comp(rcode *prog, const char *re)
|
|||||||
|
|
||||||
#define save(nn, csub) \
|
#define save(nn, csub) \
|
||||||
if (csub->ref > 1) { \
|
if (csub->ref > 1) { \
|
||||||
for (j = 0; j < subidx; j++) { \
|
s1 = freesub; \
|
||||||
if (!nsubs[j].ref) { \
|
if (s1) \
|
||||||
s1 = &nsubs[j]; \
|
freesub = (rsub*)s1->sub[0]; \
|
||||||
goto freedsub##nn; \
|
else \
|
||||||
} \
|
s1 = &nsubs[subidx++]; \
|
||||||
} \
|
|
||||||
s1 = &nsubs[subidx++]; \
|
|
||||||
freedsub##nn: \
|
|
||||||
for (j = 0; j < nsubp; j++) \
|
for (j = 0; j < nsubp; j++) \
|
||||||
s1->sub[j] = csub->sub[j]; \
|
s1->sub[j] = csub->sub[j]; \
|
||||||
csub->ref--; \
|
csub->ref--; \
|
||||||
@@ -466,6 +463,12 @@ if (csub->ref > 1) { \
|
|||||||
csub->ref = 1; \
|
csub->ref = 1; \
|
||||||
} \
|
} \
|
||||||
|
|
||||||
|
#define decref(csub) \
|
||||||
|
if (--csub->ref == 0) { \
|
||||||
|
csub->sub[0] = (char*)freesub; \
|
||||||
|
freesub = csub; \
|
||||||
|
} \
|
||||||
|
|
||||||
#define addthread(nn, list, _pc, _sub, cont) \
|
#define addthread(nn, list, _pc, _sub, cont) \
|
||||||
{ \
|
{ \
|
||||||
int i = 0, *pc = _pc; \
|
int i = 0, *pc = _pc; \
|
||||||
@@ -473,7 +476,7 @@ if (csub->ref > 1) { \
|
|||||||
rsub *sub = _sub; \
|
rsub *sub = _sub; \
|
||||||
rec##nn: \
|
rec##nn: \
|
||||||
if(plist[pc - prog->insts] == gen) { \
|
if(plist[pc - prog->insts] == gen) { \
|
||||||
sub->ref--; \
|
decref(sub) \
|
||||||
rec_check##nn: \
|
rec_check##nn: \
|
||||||
if (i) { \
|
if (i) { \
|
||||||
pc = pcs[--i]; \
|
pc = pcs[--i]; \
|
||||||
@@ -535,6 +538,7 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
|
|||||||
int *pcs[prog->splits];
|
int *pcs[prog->splits];
|
||||||
rsub *subs[prog->splits];
|
rsub *subs[prog->splits];
|
||||||
rsub *nsub = nsubs, *lsub = nsub, *matched = NULL, *s1;
|
rsub *nsub = nsubs, *lsub = nsub, *matched = NULL, *s1;
|
||||||
|
rsub *freesub = NULL;
|
||||||
rthreadlist _clist[1+prog->len];
|
rthreadlist _clist[1+prog->len];
|
||||||
rthreadlist _nlist[1+prog->len];
|
rthreadlist _nlist[1+prog->len];
|
||||||
rthreadlist *clist = _clist, *nlist = _nlist, *tmp;
|
rthreadlist *clist = _clist, *nlist = _nlist, *tmp;
|
||||||
@@ -574,7 +578,7 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
|
|||||||
subidx = 0;
|
subidx = 0;
|
||||||
goto break_for;
|
goto break_for;
|
||||||
}
|
}
|
||||||
nsub->ref--;
|
decref(nsub)
|
||||||
}
|
}
|
||||||
break_for:
|
break_for:
|
||||||
if (!c)
|
if (!c)
|
||||||
|
|||||||
Reference in New Issue
Block a user