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

Function mainposition

extlibs/lua/src/ltable.c:136–157  ·  view source on GitHub ↗

** returns the 'main' position of an element in a table (that is, ** the index of its hash value). The key comes broken (tag in 'ktt' ** and value in 'vkl') so that we can call it on keys inserted into ** nodes. */

Source from the content-addressed store, hash-verified

134** nodes.
135*/
136static Node *mainposition (const Table *t, int ktt, const Value *kvl) {
137 switch (withvariant(ktt)) {
138 case LUA_VNUMINT:
139 return hashint(t, ivalueraw(*kvl));
140 case LUA_VNUMFLT:
141 return hashmod(t, l_hashfloat(fltvalueraw(*kvl)));
142 case LUA_VSHRSTR:
143 return hashstr(t, tsvalueraw(*kvl));
144 case LUA_VLNGSTR:
145 return hashpow2(t, luaS_hashlongstr(tsvalueraw(*kvl)));
146 case LUA_VFALSE:
147 return hashboolean(t, 0);
148 case LUA_VTRUE:
149 return hashboolean(t, 1);
150 case LUA_VLIGHTUSERDATA:
151 return hashpointer(t, pvalueraw(*kvl));
152 case LUA_VLCF:
153 return hashpointer(t, fvalueraw(*kvl));
154 default:
155 return hashpointer(t, gcvalueraw(*kvl));
156 }
157}
158
159
160/*

Callers 2

mainpositionTVFunction · 0.85
luaH_newkeyFunction · 0.85

Calls 2

l_hashfloatFunction · 0.85
luaS_hashlongstrFunction · 0.85

Tested by

no test coverage detected