** returns the 'main' position of an element in a table (that is, the index ** of its hash value) */
| 115 | ** of its hash value) |
| 116 | */ |
| 117 | static 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 | /* |
no test coverage detected