Growth factor of 1.5 for stack and lexical buffer

This commit is contained in:
Roberto Ierusalimschy
2025-03-31 13:44:41 -03:00
parent 37a1b72706
commit f4123b2fc2
3 changed files with 11 additions and 11 deletions

2
ldo.c
View File

@@ -319,7 +319,7 @@ int luaD_growstack (lua_State *L, int n, int raiseerror) {
return 0; /* if not 'raiseerror', just signal it */
}
else if (n < MAXSTACK) { /* avoids arithmetic overflows */
int newsize = 2 * size; /* tentative new size */
int newsize = size + (size >> 1); /* tentative new size (size * 1.5) */
int needed = cast_int(L->top.p - L->stack.p) + n;
if (newsize > MAXSTACK) /* cannot cross the limit */
newsize = MAXSTACK;