Skip to content

Commit e38cd60

Browse files
committed
libast/regex: do not use small block size for stack (re: e311f1e)
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: ksh93/ksh#440
1 parent 9b4891a commit e38cd60

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lib/libast/regex/regcomp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3278,7 +3278,7 @@ regcomp(regex_t* p, const char* pattern, regflags_t flags)
32783278
if (!(p->env = (Env_t*)alloc(disc, 0, sizeof(Env_t))))
32793279
return fatal(disc, REG_ESPACE, pattern);
32803280
memset(p->env, 0, sizeof(*p->env));
3281-
if (!(p->env->mst = stkopen(STK_SMALL|STK_NULL)))
3281+
if (!(p->env->mst = stkopen(STK_NULL)))
32823282
return fatal(disc, REG_ESPACE, pattern);
32833283
memset(&env, 0, sizeof(env));
32843284
env.regex = p;

0 commit comments

Comments
 (0)