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

Method RawGet

table.go:251–280  ·  view source on GitHub ↗

RawGet returns an LValue associated with a given key without __index metamethod.

(key LValue)

Source from the content-addressed store, hash-verified

249
250// RawGet returns an LValue associated with a given key without __index metamethod.
251func (tb *LTable) RawGet(key LValue) LValue {
252 switch v := key.(type) {
253 case LNumber:
254 if isArrayKey(v) {
255 if tb.array == nil {
256 return LNil
257 }
258 index := int(v) - 1
259 if index >= len(tb.array) {
260 return LNil
261 }
262 return tb.array[index]
263 }
264 case LString:
265 if tb.strdict == nil {
266 return LNil
267 }
268 if ret, ok := tb.strdict[string(v)]; ok {
269 return ret
270 }
271 return LNil
272 }
273 if tb.dict == nil {
274 return LNil
275 }
276 if v, ok := tb.dict[key]; ok {
277 return v
278 }
279 return LNil
280}
281
282// RawGetInt returns an LValue at position `key` without __index metamethod.
283func (tb *LTable) RawGetInt(key int) LValue {

Callers 3

TestTableInsertFunction · 0.45
TestTableRawSetIntFunction · 0.45
baseRawGetFunction · 0.45

Calls 1

isArrayKeyFunction · 0.85

Tested by 2

TestTableInsertFunction · 0.36
TestTableRawSetIntFunction · 0.36