'clearapihash' -> 'luaS_clearcache' and moved to 'lstring.c' (which

keeps all code related to this cache)
This commit is contained in:
Roberto Ierusalimschy authored and Alug committed 2026-05-27 20:16:45 +02:00
1 parent 694e82d4f6
commit 091c6e37dd
3 files changed
+15 -14

No files matched your search

+1 -14
View File
@@ -522,19 +522,6 @@ static void remarkupvals (global_State *g) {
}
/*
** Clear API string cache. (Entries cannot be empty, so fill them with
** a non-collectable string.)
*/
static void clearapihash (global_State *g) {
int i;
for (i = 0; i < STRCACHE_SIZE; i++) {
if (luaS_iswhite(g->strcache[i])) /* will entry be collected? */
g->strcache[i] = g->memerrmsg; /* replace it with something fixed */
}
}
static void atomic (lua_State *L) {
global_State *g = G(L);
size_t udsize; /* total size of userdata to be finalized */
@@ -557,7 +544,7 @@ static void atomic (lua_State *L) {
marktmu(g); /* mark `preserved' userdata */
udsize += propagateall(g); /* remark, to propagate `preserveness' */
cleartable(g->weak); /* remove collected objects from weak tables */
clearapihash(g);
luaS_clearcache(g);
/* flip current white */
g->currentwhite = cast_byte(otherwhite(g));
g->sweepstrgc = 0;
+13
View File
@@ -75,6 +75,19 @@ static TString *newlstr (lua_State *L, const char *str, size_t l,
}
/*
** Clear API string cache. (Entries cannot be empty, so fill them with
** a non-collectable string.)
*/
void luaS_clearcache (global_State *g) {
int i;
for (i = 0; i < STRCACHE_SIZE; i++) {
if (luaS_iswhite(g->strcache[i])) /* will entry be collected? */
g->strcache[i] = g->memerrmsg; /* replace it with something fixed */
}
}
/*
** Initialize the string table and the string cache
*/
+1
View File
@@ -25,6 +25,7 @@
#define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT)
LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
LUAI_FUNC void luaS_clearcache (global_State *g);
LUAI_FUNC void luaS_init (lua_State *L);
LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e);
LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);