diff options
| author | gingerBill <bill@gingerbill.org> | 2023-12-18 22:22:08 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-12-18 22:22:08 +0000 |
| commit | 829e4cc67e4adb8283813f08f091b71fb94d975d (patch) | |
| tree | 4d4aed45768b0c73326620fa03a5443759487330 | |
| parent | beb4699b46b8e240c4ded5d0e185afcdd7f9f507 (diff) | |
Fix `assign_at_elems` to match the same logic as `assign_at_elem_string`
| -rw-r--r-- | core/runtime/core_builtin.odin | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/core/runtime/core_builtin.odin b/core/runtime/core_builtin.odin index 0348a93df..eb9315fab 100644 --- a/core/runtime/core_builtin.odin +++ b/core/runtime/core_builtin.odin @@ -234,6 +234,8 @@ delete :: proc{ delete_dynamic_array, delete_slice, delete_map, + delete_soa_slice, + delete_soa_dynamic_array, } @@ -587,11 +589,14 @@ assign_at_elem :: proc(array: ^$T/[dynamic]$E, index: int, arg: E, loc := #calle @builtin assign_at_elems :: proc(array: ^$T/[dynamic]$E, index: int, args: ..E, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error { - if index+len(args) < len(array) { + new_size := index + len(arg) + if len(args) == 0 { + ok = true + } else if new_size < len(array) { copy(array[index:], args) ok = true } else { - resize(array, index+1+len(args), loc) or_return + resize(array, new_size, loc) or_return copy(array[index:], args) ok = true } |