Skip to content

Commit 3272ef2

Browse files
author
Achille Roussel
committed
add more documentation for bswap
1 parent 67a137d commit 3272ef2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

bswap/swap64.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ package bswap
22

33
import _ "github.com/segmentio/asm/cpu"
44

5-
// Swap64 performs an in-place byte swap on each qword of the input buffer.
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.
610
func Swap64(b []byte) {
711
if len(b)%8 != 0 {
8-
panic("swap64 expects full qwords")
12+
panic("swap64 expects the input to contain full 64 bits elements")
913
}
1014
swap64(b)
1115
}

0 commit comments

Comments
 (0)