Debian Codegraph @

bswap/swap64.go

raw
1 package bswap
2
3 import _ "github.com/segmentio/asm/cpu"
4
5 // Swap64 performs an in-place byte swap on each 64 bits elements in b.
6 //
7 // This function is useful when dealing with big-endian input; by converting it
8 // to little-endian, the data can then be compared using native CPU instructions
9 // instead of having to employ often slower byte comparison algorithms.
10 func Swap64(b []byte) {
11 if len(b)%8 != 0 {
12 panic("swap64 expects the input to contain full 64 bits elements")
13 }
14 swap64(b)
15 }