Skip to content

Commit

Permalink
Merge pull request #180 from dgriffie79/fix/array-insert
Browse files Browse the repository at this point in the history
fix indexing error in Array.insert
  • Loading branch information
brendanfh authored Jan 4, 2025
2 parents 55164b8 + 4c9f3f7 commit 00fd90b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/container/array.onyx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Array.insert :: (arr: &[..] $T, idx: u32, new_arr: [] T) -> bool {
if !Array.ensure_capacity(arr, arr.count + new_arr.count) do return false;

arr.count += new_arr.count;
while i := arr.count; i > idx {
while i := arr.count - 1; i > idx {
arr.data[i] = arr.data[i - new_arr.count];
i -= 1;
}
Expand All @@ -198,7 +198,7 @@ Array.insert_empty :: (arr: &[..] $T, idx: u32) -> bool {
if !Array.ensure_capacity(arr, arr.count + 1) do return false;

arr.count += 1;
while i := arr.count; i > idx {
while i := arr.count - 1; i > idx {
arr.data[i] = arr.data[i - 1];
i -= 1;
}
Expand Down

0 comments on commit 00fd90b

Please sign in to comment.