RawSetH sets a given LValue to a given index without the __newindex metamethod.
(key LValue, value LValue)
| 223 | |
| 224 | // RawSetH sets a given LValue to a given index without the __newindex metamethod. |
| 225 | func (tb *LTable) RawSetH(key LValue, value LValue) { |
| 226 | if s, ok := key.(LString); ok { |
| 227 | tb.RawSetString(string(s), value) |
| 228 | return |
| 229 | } |
| 230 | if tb.dict == nil { |
| 231 | tb.dict = make(map[LValue]LValue, len(tb.strdict)) |
| 232 | } |
| 233 | if tb.keys == nil { |
| 234 | tb.keys = []LValue{} |
| 235 | tb.k2i = map[LValue]int{} |
| 236 | } |
| 237 | |
| 238 | if value == LNil { |
| 239 | // TODO tb.keys and tb.k2i should also be removed |
| 240 | delete(tb.dict, key) |
| 241 | } else { |
| 242 | tb.dict[key] = value |
| 243 | if _, ok := tb.k2i[key]; !ok { |
| 244 | tb.k2i[key] = len(tb.keys) |
| 245 | tb.keys = append(tb.keys, key) |
| 246 | } |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | // RawGet returns an LValue associated with a given key without __index metamethod. |
| 251 | func (tb *LTable) RawGet(key LValue) LValue { |