1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

libast/regex: do not use small block size for stack (re: de511cfb)

Opening the match stack with the STK_SMALL flag causes the stk code
to allocate memory in blocks of 64*sizeof(char*) instead of
1024*sizeof(char*). This caused a significant slowdown which was
exposed by the extglob.ksh module of shbench. Thanks to @JohnoKing
for noticing and reporting the problem.

src/lib/libast/regex/regcomp.c: regcomp():
- Remove STK_SMALL from the stkopen() option bit flags.

Resolves: https://github.com/ksh93/ksh/issues/440
This commit is contained in:
Martijn Dekker 2022-01-28 21:06:36 +00:00
parent 304648d0c5
commit 39673b1207

View file

@ -3278,7 +3278,7 @@ regcomp(regex_t* p, const char* pattern, regflags_t flags)
if (!(p->env = (Env_t*)alloc(disc, 0, sizeof(Env_t))))
return fatal(disc, REG_ESPACE, pattern);
memset(p->env, 0, sizeof(*p->env));
if (!(p->env->mst = stkopen(STK_SMALL|STK_NULL)))
if (!(p->env->mst = stkopen(STK_NULL)))
return fatal(disc, REG_ESPACE, pattern);
memset(&env, 0, sizeof(env));
env.regex = p;