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

Function luaH_psetshortstr

third-party/lua-5.5.0/src/ltable.c:1098–1121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1096*/
1097
1098int luaH_psetshortstr (Table *t, TString *key, TValue *val) {
1099 const TValue *slot = luaH_Hgetshortstr(t, key);
1100 if (!ttisnil(slot)) { /* key already has a value? (all too common) */
1101 setobj(((lua_State*)NULL), cast(TValue*, slot), val); /* update it */
1102 return HOK; /* done */
1103 }
1104 else if (checknoTM(t->metatable, TM_NEWINDEX)) { /* no metamethod? */
1105 if (ttisnil(val)) /* new value is nil? */
1106 return HOK; /* done (value is already nil/absent) */
1107 if (isabstkey(slot) && /* key is absent? */
1108 !(isblack(t) && iswhite(key))) { /* and don't need barrier? */
1109 TValue tk; /* key as a TValue */
1110 setsvalue(cast(lua_State *, NULL), &tk, key);
1111 if (insertkey(t, &tk, val)) { /* insert key, if there is space */
1112 invalidateTMcache(t);
1113 return HOK;
1114 }
1115 }
1116 }
1117 /* Else, either table has new-index metamethod, or it needs barrier,
1118 or it needs to rehash for the new key. In any of these cases, the
1119 operation cannot be completed here. Return a code for the caller. */
1120 return retpsetcode(t, slot);
1121}
1122
1123
1124int luaH_psetstr (Table *t, TString *key, TValue *val) {

Callers 2

luaH_psetstrFunction · 0.85
luaH_psetFunction · 0.85

Calls 3

luaH_HgetshortstrFunction · 0.85
insertkeyFunction · 0.85
retpsetcodeFunction · 0.85

Tested by

no test coverage detected