1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

array: use __new_array everywhere

This commit is contained in:
Alexander Medvednikov
2020-04-25 09:10:51 +02:00
parent fbcdffbbc8
commit 9229a963ed
2 changed files with 2 additions and 34 deletions

View File

@ -202,38 +202,6 @@ pub fn (a array) last() voidptr {
return byteptr(a.data) + (a.len - 1) * a.element_size
}
/*
// array.left returns a new array using the same buffer as the given array
// with the first `n` elements of the given array.
fn (a array) left(n int) array {
// $if !no_bounds_checking? {
// if n < 0 {
// panic('array.left: index is negative (n == $n)')
// }
// }
if n >= a.len {
return a.slice(0, a.len)
}
return a.slice(0, n)
}
// array.right returns an array using same buffer as the given array
// but starting with the element of the given array beyond the index `n`.
// If `n` is bigger or equal to the length of the given array,
// returns an empty array of the same type as the given array.
fn (a array) right(n int) array {
// $if !no_bounds_checking? {
// if n < 0 {
// panic('array.right: index is negative (n == $n)')
// }
// }
if n >= a.len {
return new_array(0, 0, a.element_size)
}
return a.slice(n, a.len)
}
*/
// array.slice returns an array using the same buffer as original array
// but starting from the `start` element and ending with the element before
// the `end` element of the original array with the length and capacity