mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-14 23:07:50 +00:00
24bb66e606
ArrayReverse copies it's argument only if it's len is > 1. It needs to be consistent in all cases.
10 lines
251 B
Go
10 lines
251 B
Go
package util
|
|
|
|
// ArrayReverse returns a reversed version of the given byte slice.
|
|
func ArrayReverse(b []byte) []byte {
|
|
dest := make([]byte, len(b))
|
|
for i, j := 0, len(b)-1; i <= j; i, j = i+1, j-1 {
|
|
dest[i], dest[j] = b[j], b[i]
|
|
}
|
|
return dest
|
|
}
|