neoneo-go/pkg/util/array.go
Anastasia Prasolova a058598ecc Parse stack params (#119)
* small fixes

* gofmt

* bytearray parsing

* tests

* removed unnecessary files

* added more types for bytearray

* iter

* made TryParseArray parameter variadic

* fixes after review

* fix after review

* misprints

* updated array reverse

* imports/fmt

* naming
2019-02-05 13:22:10 +01:00

14 lines
330 B
Go

package util
// ArrayReverse return a reversed version of the given byte slice.
func ArrayReverse(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; i, j = i+1, j-1 {
dest[i], dest[j] = b[j], b[i]
}
return dest
}