From 55ac40f859ad8e28fe71a8801d49f4a4140e8aa3 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 20 Jun 2024 13:43:33 -0300 Subject: Cleaning of llimits.h Several definitions that don't need to be "global" (that is, that concerns only specific parts of the code) moved out of llimits.h, to more appropriate places. --- lstring.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'lstring.c') diff --git a/lstring.c b/lstring.c index a374c965..86ee2411 100644 --- a/lstring.c +++ b/lstring.c @@ -25,7 +25,17 @@ /* ** Maximum size for string table. */ -#define MAXSTRTB cast_int(luaM_limitN(MAX_INT, TString*)) +#define MAXSTRTB cast_int(luaM_limitN(INT_MAX, TString*)) + +/* +** Initial size for the string table (must be power of 2). +** The Lua core alone registers ~50 strings (reserved words + +** metaevent keys + a few others). Libraries would typically add +** a few dozens more. +*/ +#if !defined(MINSTRTABSIZE) +#define MINSTRTABSIZE 128 +#endif /* @@ -188,9 +198,9 @@ void luaS_remove (lua_State *L, TString *ts) { static void growstrtab (lua_State *L, stringtable *tb) { - if (l_unlikely(tb->nuse == MAX_INT)) { /* too many strings? */ + if (l_unlikely(tb->nuse == INT_MAX)) { /* too many strings? */ luaC_fullgc(L, 1); /* try to free some... */ - if (tb->nuse == MAX_INT) /* still too many? */ + if (tb->nuse == INT_MAX) /* still too many? */ luaM_error(L); /* cannot even create a message... */ } if (tb->size <= MAXSTRTB / 2) /* can grow string table? */ -- cgit v1.2.3-55-g6feb