TODO(justin): these might be improved by making arrays into an interface and then introducing a ConcatenatedArray implementation which just references two existing arrays. This would optimize the common case of appending an element (or array) to an array from O(n) to O(1).
()
| 205 | // existing arrays. This would optimize the common case of appending an element |
| 206 | // (or array) to an array from O(n) to O(1). |
| 207 | func initArrayElementConcatenation() { |
| 208 | for _, t := range types.Scalar { |
| 209 | typ := t |
| 210 | BinOps[Concat] = append(BinOps[Concat], &BinOp{ |
| 211 | LeftType: types.MakeArray(typ), |
| 212 | RightType: typ, |
| 213 | ReturnType: types.MakeArray(typ), |
| 214 | NullableArgs: true, |
| 215 | Volatility: VolatilityImmutable, |
| 216 | }) |
| 217 | |
| 218 | BinOps[Concat] = append(BinOps[Concat], &BinOp{ |
| 219 | LeftType: typ, |
| 220 | RightType: types.MakeArray(typ), |
| 221 | ReturnType: types.MakeArray(typ), |
| 222 | NullableArgs: true, |
| 223 | Volatility: VolatilityImmutable, |
| 224 | }) |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | func initArrayToArrayConcatenation() { |
| 229 | for _, t := range types.Scalar { |