Skip to content

Commit 00fd90b

Browse files
authored
Merge pull request #180 from dgriffie79/fix/array-insert
fix indexing error in Array.insert
2 parents 55164b8 + 4c9f3f7 commit 00fd90b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

core/container/array.onyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ Array.insert :: (arr: &[..] $T, idx: u32, new_arr: [] T) -> bool {
181181
if !Array.ensure_capacity(arr, arr.count + new_arr.count) do return false;
182182

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

200200
arr.count += 1;
201-
while i := arr.count; i > idx {
201+
while i := arr.count - 1; i > idx {
202202
arr.data[i] = arr.data[i - 1];
203203
i -= 1;
204204
}

0 commit comments

Comments
 (0)