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

Function equalkey

3rd/lua-5.4.3/src/ltable.c:207–227  ·  view source on GitHub ↗

** Check whether key 'k1' is equal to the key in node 'n2'. This ** equality is raw, so there are no metamethods. Floats with integer ** values have been normalized, so integers cannot be equal to ** floats. It is assumed that 'eqshrstr' is simply pointer equality, so ** that short strings are handled in the default case. ** A true 'deadok' means to accept dead keys as equal to their original ** v

Source from the content-addressed store, hash-verified

205** some other valid item on the table or nil.)
206*/
207static int equalkey (const TValue *k1, const Node *n2, int deadok) {
208 if ((rawtt(k1) != keytt(n2)) && /* not the same variants? */
209 !(deadok && keyisdead(n2) && iscollectable(k1)))
210 return 0; /* cannot be same key */
211 switch (keytt(n2)) {
212 case LUA_VNIL: case LUA_VFALSE: case LUA_VTRUE:
213 return 1;
214 case LUA_VNUMINT:
215 return (ivalue(k1) == keyival(n2));
216 case LUA_VNUMFLT:
217 return luai_numeq(fltvalue(k1), fltvalueraw(keyval(n2)));
218 case LUA_VLIGHTUSERDATA:
219 return pvalue(k1) == pvalueraw(keyval(n2));
220 case LUA_VLCF:
221 return fvalue(k1) == fvalueraw(keyval(n2));
222 case ctb(LUA_VLNGSTR):
223 return luaS_eqlngstr(tsvalue(k1), keystrval(n2));
224 default:
225 return gcvalue(k1) == gcvalueraw(keyval(n2));
226 }
227}
228
229
230/*

Callers 1

getgenericFunction · 0.85

Calls 1

luaS_eqlngstrFunction · 0.85

Tested by

no test coverage detected