mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-13 05:45:02 +00:00
15 lines
328 B
Go
15 lines
328 B
Go
package slice
|
|
|
|
// SliceReverse return a reversed version of the given byte slice.
|
|
func Reverse(b []byte) []byte {
|
|
// Protect from big.Ints that have 1 len bytes.
|
|
if len(b) < 2 {
|
|
return b
|
|
}
|
|
|
|
dest := make([]byte, len(b))
|
|
for i, j := 0, len(b)-1; i < j+1; i, j = i+1, j-1 {
|
|
dest[i], dest[j] = b[j], b[i]
|
|
}
|
|
return dest
|
|
}
|