MCPcopy Index your code
hub / github.com/yuin/gopher-lua / RawSetH

Method RawSetH

table.go:225–248  ·  view source on GitHub ↗

RawSetH sets a given LValue to a given index without the __newindex metamethod.

(key LValue, value LValue)

Source from the content-addressed store, hash-verified

223
224// RawSetH sets a given LValue to a given index without the __newindex metamethod.
225func (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.
251func (tb *LTable) RawGet(key LValue) LValue {

Callers 5

RawSetMethod · 0.95
RawSetIntMethod · 0.95
TestTableRawSetHFunction · 0.80
TestTableRawGetHFunction · 0.80
TestTableForEachFunction · 0.80

Calls 1

RawSetStringMethod · 0.95

Tested by 3

TestTableRawSetHFunction · 0.64
TestTableRawGetHFunction · 0.64
TestTableForEachFunction · 0.64