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

array: reverse empty arrays correctly

This commit is contained in:
Alexey
2020-02-29 22:44:02 +03:00
committed by GitHub
parent c1e095e587
commit cbffbf3438
2 changed files with 7 additions and 0 deletions

View File

@ -328,6 +328,9 @@ pub fn (a mut array) push_many(val voidptr, size int) {
// array.reverse returns a new array with the elements of
// the original array in reverse order.
pub fn (a array) reverse() array {
if a.len < 2 {
return a
}
arr := array{
len: a.len
cap: a.cap