MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / mainposition

Function mainposition

third-party/lua-5.2.4/src/ltable.c:97–120  ·  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

95** of its hash value)
96*/
97static Node *mainposition (const Table *t, const TValue *key) {
98 switch (ttype(key)) {
99 case LUA_TNUMBER:
100 return hashnum(t, nvalue(key));
101 case LUA_TLNGSTR: {
102 TString *s = rawtsvalue(key);
103 if (s->tsv.extra == 0) { /* no hash? */
104 s->tsv.hash = luaS_hash(getstr(s), s->tsv.len, s->tsv.hash);
105 s->tsv.extra = 1; /* now it has its hash */
106 }
107 return hashstr(t, rawtsvalue(key));
108 }
109 case LUA_TSHRSTR:
110 return hashstr(t, rawtsvalue(key));
111 case LUA_TBOOLEAN:
112 return hashboolean(t, bvalue(key));
113 case LUA_TLIGHTUSERDATA:
114 return hashpointer(t, pvalue(key));
115 case LUA_TLCF:
116 return hashpointer(t, fvalue(key));
117 default:
118 return hashpointer(t, gcvalue(key));
119 }
120}
121
122
123/*

Callers 4

findindexFunction · 0.70
luaH_newkeyFunction · 0.70
luaH_getFunction · 0.70
luaH_mainpositionFunction · 0.70

Calls 2

hashnumFunction · 0.70
luaS_hashFunction · 0.70

Tested by

no test coverage detected