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

Method RawSetInt

table.go:178–199  ·  view source on GitHub ↗

RawSetInt sets a given LValue at a position `key` without the __newindex metamethod.

(key int, value LValue)

Source from the content-addressed store, hash-verified

176
177// RawSetInt sets a given LValue at a position `key` without the __newindex metamethod.
178func (tb *LTable) RawSetInt(key int, value LValue) {
179 if key < 1 || key >= MaxArrayIndex {
180 tb.RawSetH(LNumber(key), value)
181 return
182 }
183 if tb.array == nil {
184 tb.array = make([]LValue, 0, 32)
185 }
186 index := key - 1
187 alen := len(tb.array)
188 switch {
189 case index == alen:
190 tb.array = append(tb.array, value)
191 case index > alen:
192 for i := 0; i < (index - alen); i++ {
193 tb.array = append(tb.array, LNil)
194 }
195 tb.array = append(tb.array, value)
196 case index < alen:
197 tb.array[index] = value
198 }
199}
200
201// RawSetString sets a given LValue to a given string index without the __newindex metamethod.
202func (tb *LTable) RawSetString(key string, value LValue) {

Callers 10

InsertMethod · 0.95
OpenPackageFunction · 0.45
TestTableLenFunction · 0.45
TestTableAppendFunction · 0.45
TestTableRawSetIntFunction · 0.45
OpenIoFunction · 0.45
ioInputFunction · 0.45
ioOutputFunction · 0.45
initFunction · 0.45
initFunction · 0.45

Calls 2

RawSetHMethod · 0.95
LNumberTypeAlias · 0.85

Tested by 3

TestTableLenFunction · 0.36
TestTableAppendFunction · 0.36
TestTableRawSetIntFunction · 0.36