RawSetString sets a given LValue to a given string index without the __newindex metamethod.
(key string, value LValue)
| 200 | |
| 201 | // RawSetString sets a given LValue to a given string index without the __newindex metamethod. |
| 202 | func (tb *LTable) RawSetString(key string, value LValue) { |
| 203 | if tb.strdict == nil { |
| 204 | tb.strdict = make(map[string]LValue, defaultHashCap) |
| 205 | } |
| 206 | if tb.keys == nil { |
| 207 | tb.keys = []LValue{} |
| 208 | tb.k2i = map[LValue]int{} |
| 209 | } |
| 210 | |
| 211 | if value == LNil { |
| 212 | // TODO tb.keys and tb.k2i should also be removed |
| 213 | delete(tb.strdict, key) |
| 214 | } else { |
| 215 | tb.strdict[key] = value |
| 216 | lkey := LString(key) |
| 217 | if _, ok := tb.k2i[lkey]; !ok { |
| 218 | tb.k2i[lkey] = len(tb.keys) |
| 219 | tb.keys = append(tb.keys, lkey) |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | // RawSetH sets a given LValue to a given index without the __newindex metamethod. |
| 225 | func (tb *LTable) RawSetH(key LValue, value LValue) { |
no test coverage detected