util: move ArrayReverse into package of its own

Leave just uint160 and uint256 types in util.
This commit is contained in:
Roman Khimov 2021-07-18 15:55:37 +03:00
parent 588f3fbbd3
commit 100e97d772
8 changed files with 28 additions and 21 deletions

14
pkg/util/slice/array.go Normal file
View file

@ -0,0 +1,14 @@
/*
Package slice contains byte slice helpers.
*/
package slice
// CopyReverse returns a new byte slice containing reversed version of the
// original.
func CopyReverse(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
}