Append appends a given LValue to this LTable.
(value LValue)
| 64 | |
| 65 | // Append appends a given LValue to this LTable. |
| 66 | func (tb *LTable) Append(value LValue) { |
| 67 | if value == LNil { |
| 68 | return |
| 69 | } |
| 70 | if tb.array == nil { |
| 71 | tb.array = make([]LValue, 0, defaultArrayCap) |
| 72 | } |
| 73 | if len(tb.array) == 0 || tb.array[len(tb.array)-1] != LNil { |
| 74 | tb.array = append(tb.array, value) |
| 75 | } else { |
| 76 | i := len(tb.array) - 2 |
| 77 | for ; i >= 0; i-- { |
| 78 | if tb.array[i] != LNil { |
| 79 | break |
| 80 | } |
| 81 | } |
| 82 | tb.array[i+1] = value |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | // Insert inserts a given LValue at position `i` in this table. |
| 87 | func (tb *LTable) Insert(i int, value LValue) { |
no outgoing calls