MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / traverseweakvalue

Function traverseweakvalue

extlibs/lua/src/lgc.c:383–402  ·  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

381** put it in 'weak' list, to be cleared.
382*/
383static void traverseweakvalue (global_State *g, Table *h) {
384 Node *n, *limit = gnodelast(h);
385 /* if there is array part, assume it may have white values (it is not
386 worth traversing it now just to check) */
387 int hasclears = (h->alimit > 0);
388 for (n = gnode(h, 0); n < limit; n++) { /* traverse hash part */
389 if (isempty(gval(n))) /* entry is empty? */
390 clearkey(n); /* clear its key */
391 else {
392 lua_assert(!keyisnil(n));
393 markkey(g, n);
394 if (!hasclears && iscleared(g, gcvalueN(gval(n)))) /* a white value? */
395 hasclears = 1; /* table will have to be cleared */
396 }
397 }
398 if (g->gcstate == GCSatomic && hasclears)
399 linkgclist(h, g->weak); /* has to be cleared later */
400 else
401 linkgclist(h, g->grayagain); /* must retraverse it in atomic phase */
402}
403
404
405/*

Callers 1

traversetableFunction · 0.85

Calls 2

clearkeyFunction · 0.85
isclearedFunction · 0.85

Tested by

no test coverage detected