mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
array: simplify reverse() memcpy call
This commit is contained in:
parent
2f27758a4b
commit
4fac09bcb4
@ -338,7 +338,8 @@ pub fn (a array) reverse() array {
|
|||||||
data: vcalloc(a.cap * a.element_size)
|
data: vcalloc(a.cap * a.element_size)
|
||||||
}
|
}
|
||||||
for i in 0..a.len {
|
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
|
return arr
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user