MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / traverseweakvalue

Function traverseweakvalue

3rd/lua-5.4.3/src/lgc.c:440–459  ·  view source on GitHub ↗

** Traverse a table with weak values and link it to proper list. During ** propagate phase, keep it in 'grayagain' list, to be revisited in the ** atomic phase. In the atomic phase, if table has any white value, ** put it in 'weak' list, to be cleared. */

Source from the content-addressed store, hash-verified

438** put it in 'weak' list, to be cleared.
439*/
440static void traverseweakvalue (global_State *g, Table *h) {
441 Node *n, *limit = gnodelast(h);
442 /* if there is array part, assume it may have white values (it is not
443 worth traversing it now just to check) */
444 int hasclears = (h->alimit > 0);
445 for (n = gnode(h, 0); n < limit; n++) { /* traverse hash part */
446 if (isempty(gval(n))) /* entry is empty? */
447 clearkey(n); /* clear its key */
448 else {
449 lua_assert(!keyisnil(n));
450 markkey(g, n);
451 if (!hasclears && iscleared(g, gcvalueN(gval(n)))) /* a white value? */
452 hasclears = 1; /* table will have to be cleared */
453 }
454 }
455 if (g->gcstate == GCSatomic && hasclears)
456 linkgclist(h, g->weak); /* has to be cleared later */
457 else
458 linkgclist(h, g->grayagain); /* must retraverse it in atomic phase */
459}
460
461
462/*

Callers 1

traversetableFunction · 0.85

Calls 2

clearkeyFunction · 0.85
isclearedFunction · 0.85

Tested by

no test coverage detected