array: simplify reverse() memcpy call

pull/4081/head
Alexander Medvednikov 2020-03-20 16:51:36 +01:00
parent 2f27758a4b
commit 4fac09bcb4
1 changed files with 2 additions and 1 deletions

View File

@ -338,7 +338,8 @@ pub fn (a array) reverse() array {
data: vcalloc(a.cap * a.element_size)
}
for i in 0..a.len {
C.memcpy(arr.data + i * arr.element_size, &a[a.len - 1 - i], arr.element_size)
//C.memcpy(arr.data + i * arr.element_size, &a[a.len - 1 - i], arr.element_size)
C.memcpy(arr.data + i * arr.element_size, a.data + (a.len - 1 - i) * arr.element_size, arr.element_size)
}
return arr
}