MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / addk

Function addk

deps/lua/src/lcode.c:229–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227
228
229static int addk (FuncState *fs, TValue *k, TValue *v) {
230 lua_State *L = fs->L;
231 TValue *idx = luaH_set(L, fs->h, k);
232 Proto *f = fs->f;
233 int oldsize = f->sizek;
234 if (ttisnumber(idx)) {
235 lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v));
236 return cast_int(nvalue(idx));
237 }
238 else { /* constant not found; create a new entry */
239 setnvalue(idx, cast_num(fs->nk));
240 luaM_growvector(L, f->k, fs->nk, f->sizek, TValue,
241 MAXARG_Bx, "constant table overflow");
242 while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
243 setobj(L, &f->k[fs->nk], v);
244 luaC_barrier(L, f, v);
245 return fs->nk++;
246 }
247}
248
249
250int luaK_stringK (FuncState *fs, TString *s) {

Callers 4

luaK_stringKFunction · 0.85
luaK_numberKFunction · 0.85
boolKFunction · 0.85
nilKFunction · 0.85

Calls 2

luaH_setFunction · 0.85
luaO_rawequalObjFunction · 0.85

Tested by

no test coverage detected