mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 14:48:47 +00:00
[runtime] fix insert_at procedure group.
This commit is contained in:
@@ -386,12 +386,13 @@ insert_at_elem :: proc(array: ^$T/[dynamic]$E, index: int, arg: E, loc := #calle
|
|||||||
if array == nil {
|
if array == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
n := len(array)
|
n := max(len(array), index)
|
||||||
m :: 1
|
m :: 1
|
||||||
resize(array, n+m, loc)
|
new_size := n + m
|
||||||
if n+m <= len(array) {
|
|
||||||
|
if resize(array, new_size, loc) {
|
||||||
when size_of(E) != 0 {
|
when size_of(E) != 0 {
|
||||||
copy(array[index+m:], array[index:])
|
copy(array[index + m:], array[index:])
|
||||||
array[index] = arg
|
array[index] = arg
|
||||||
}
|
}
|
||||||
ok = true
|
ok = true
|
||||||
@@ -409,12 +410,13 @@ insert_at_elems :: proc(array: ^$T/[dynamic]$E, index: int, args: ..E, loc := #c
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
n := len(array)
|
n := max(len(array), index)
|
||||||
m := len(args)
|
m := len(args)
|
||||||
resize(array, n+m, loc)
|
new_size := n + m
|
||||||
if n+m <= len(array) {
|
|
||||||
|
if resize(array, new_size, loc) {
|
||||||
when size_of(E) != 0 {
|
when size_of(E) != 0 {
|
||||||
copy(array[index+m:], array[index:])
|
copy(array[index + m:], array[index:])
|
||||||
copy(array[index:], args)
|
copy(array[index:], args)
|
||||||
}
|
}
|
||||||
ok = true
|
ok = true
|
||||||
@@ -423,21 +425,22 @@ insert_at_elems :: proc(array: ^$T/[dynamic]$E, index: int, args: ..E, loc := #c
|
|||||||
}
|
}
|
||||||
|
|
||||||
@builtin
|
@builtin
|
||||||
insert_at_elem_string :: proc(array: ^$T/[dynamic]$E/u8, index: int, arg: string, loc := #caller_location) -> (ok: bool) #no_bounds_check {
|
insert_at_elem_string :: proc(array: ^$T/[dynamic]$E/u8, index: int, arg: string, loc := #caller_location) -> (ok: bool) {
|
||||||
if array == nil {
|
if array == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(args) == 0 {
|
if len(arg) == 0 {
|
||||||
ok = true
|
ok = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
n := len(array)
|
n := max(len(array), index)
|
||||||
m := len(args)
|
m := len(arg)
|
||||||
resize(array, n+m, loc)
|
new_size := n + m
|
||||||
if n+m <= len(array) {
|
|
||||||
|
if resize(array, new_size, loc) {
|
||||||
copy(array[index+m:], array[index:])
|
copy(array[index+m:], array[index:])
|
||||||
copy(array[index:], args)
|
copy(array[index:], arg)
|
||||||
ok = true
|
ok = true
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user