don't use memset (bad complexity)
This commit is contained in:
11
pike.c
11
pike.c
@@ -550,7 +550,6 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
|
|||||||
rthread _clist[prog->len];
|
rthread _clist[prog->len];
|
||||||
rthread _nlist[prog->len];
|
rthread _nlist[prog->len];
|
||||||
rthread *clist = _clist, *nlist = _nlist, *tmp;
|
rthread *clist = _clist, *nlist = _nlist, *tmp;
|
||||||
memset(nsubs, 0, rsubsize * (prog->len - prog->splits));
|
|
||||||
for(i = 0; i < nsubp; i++)
|
for(i = 0; i < nsubp; i++)
|
||||||
subp[i] = NULL;
|
subp[i] = NULL;
|
||||||
gen = prog->gen;
|
gen = prog->gen;
|
||||||
@@ -591,18 +590,16 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
|
|||||||
jmp_start:
|
jmp_start:
|
||||||
newsub()
|
newsub()
|
||||||
s1->ref = 1;
|
s1->ref = 1;
|
||||||
|
for (i = 1; i < nsubp; i++)
|
||||||
|
s1->sub[i] = NULL;
|
||||||
s1->sub[0] = sp + l;
|
s1->sub[0] = sp + l;
|
||||||
addthread(1, clist, clistidx, insts, s1)
|
addthread(1, clist, clistidx, insts, s1)
|
||||||
} else if (!clistidx)
|
} else if (!clistidx)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(matched) {
|
if(matched) {
|
||||||
for(i = 0; i < nsubp; i+=2) {
|
for(i = 0; i < nsubp; i++)
|
||||||
if (matched->sub[i] && matched->sub[i+1]) {
|
subp[i] = matched->sub[i];
|
||||||
subp[i] = matched->sub[i];
|
|
||||||
subp[i+1] = matched->sub[i+1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_return(1)
|
_return(1)
|
||||||
}
|
}
|
||||||
_return(0)
|
_return(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user