MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / mainpositionTV

Function mainpositionTV

lib/lua/src/ltable.c:151–186  ·  view source on GitHub ↗

** returns the 'main' position of an element in a table (that is, ** the index of its hash value). */

Source from the content-addressed store, hash-verified

149** the index of its hash value).
150*/
151static Node *mainpositionTV (const Table *t, const TValue *key) {
152 switch (ttypetag(key)) {
153 case LUA_VNUMINT: {
154 lua_Integer i = ivalue(key);
155 return hashint(t, i);
156 }
157 case LUA_VNUMFLT: {
158 lua_Number n = fltvalue(key);
159 return hashmod(t, l_hashfloat(n));
160 }
161 case LUA_VSHRSTR: {
162 TString *ts = tsvalue(key);
163 return hashstr(t, ts);
164 }
165 case LUA_VLNGSTR: {
166 TString *ts = tsvalue(key);
167 return hashpow2(t, luaS_hashlongstr(ts));
168 }
169 case LUA_VFALSE:
170 return hashboolean(t, 0);
171 case LUA_VTRUE:
172 return hashboolean(t, 1);
173 case LUA_VLIGHTUSERDATA: {
174 void *p = pvalue(key);
175 return hashpointer(t, p);
176 }
177 case LUA_VLCF: {
178 lua_CFunction f = fvalue(key);
179 return hashpointer(t, f);
180 }
181 default: {
182 GCObject *o = gcvalue(key);
183 return hashpointer(t, o);
184 }
185 }
186}
187
188
189l_sinline Node *mainpositionfromnode (const Table *t, Node *nd) {

Callers 4

mainpositionfromnodeFunction · 0.85
getgenericFunction · 0.85
luaH_newkeyFunction · 0.85
luaH_mainpositionFunction · 0.85

Calls 3

hashintFunction · 0.85
l_hashfloatFunction · 0.85
luaS_hashlongstrFunction · 0.85

Tested by

no test coverage detected