MCPcopy Create free account
hub / github.com/DFHack/dfhack / mainposition

Function mainposition

depends/lua/src/ltable.c:117–137  ·  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

115** of its hash value)
116*/
117static Node *mainposition (const Table *t, const TValue *key) {
118 switch (ttype(key)) {
119 case LUA_TNUMINT:
120 return hashint(t, ivalue(key));
121 case LUA_TNUMFLT:
122 return hashmod(t, l_hashfloat(fltvalue(key)));
123 case LUA_TSHRSTR:
124 return hashstr(t, tsvalue(key));
125 case LUA_TLNGSTR:
126 return hashpow2(t, luaS_hashlongstr(tsvalue(key)));
127 case LUA_TBOOLEAN:
128 return hashboolean(t, bvalue(key));
129 case LUA_TLIGHTUSERDATA:
130 return hashpointer(t, pvalue(key));
131 case LUA_TLCF:
132 return hashpointer(t, fvalue(key));
133 default:
134 lua_assert(!ttisdeadkey(key));
135 return hashpointer(t, gcvalue(key));
136 }
137}
138
139
140/*

Callers 4

findindexFunction · 0.85
luaH_newkeyFunction · 0.85
getgenericFunction · 0.85
luaH_mainpositionFunction · 0.85

Calls 2

l_hashfloatFunction · 0.85
luaS_hashlongstrFunction · 0.85

Tested by

no test coverage detected