(l *State, k, v value)
| 116 | } |
| 117 | |
| 118 | func (t *table) put(l *State, k, v value) { |
| 119 | switch k := k.(type) { |
| 120 | case nil: |
| 121 | l.runtimeError("table index is nil") |
| 122 | case float64: |
| 123 | if i := int(k); float64(i) == k { |
| 124 | t.putAtInt(i, v) |
| 125 | } else if math.IsNaN(k) { |
| 126 | l.runtimeError("table index is NaN") |
| 127 | } else if v == nil { |
| 128 | delete(t.hash, k) |
| 129 | } else { |
| 130 | t.addOrInsertHash(k, v) |
| 131 | } |
| 132 | case string: |
| 133 | if v == nil { |
| 134 | delete(t.hash, k) |
| 135 | } else { |
| 136 | t.addOrInsertHash(k, v) |
| 137 | } |
| 138 | default: |
| 139 | if v == nil { |
| 140 | delete(t.hash, k) |
| 141 | } else { |
| 142 | t.addOrInsertHash(k, v) |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | // OPT: tryPut is an optimized variant of the at/put pair used by setTableAt to avoid hashing the key twice. |
| 148 | func (t *table) tryPut(l *State, k, v value) bool { |
no test coverage detected