speedup Block by casting to array, not slice

This commit is contained in:
lukechampine
2018-10-11 17:48:17 -04:00
parent 62a404d90e
commit ab5bbcecc5
3 changed files with 11 additions and 9 deletions
+3 -3
View File
@@ -97,9 +97,9 @@ func Byte(dst, a []byte, b byte) int {
func Block(dst, a, b []byte) {
// profiling indicates that for 16-byte blocks, the cost of a function
// call outweighs the SSE/AVX speedup
dw := *(*[]uintptr)(unsafe.Pointer(&dst))
aw := *(*[]uintptr)(unsafe.Pointer(&a))
bw := *(*[]uintptr)(unsafe.Pointer(&b))
dw := (*[2]uintptr)(unsafe.Pointer(&dst[0]))
aw := (*[2]uintptr)(unsafe.Pointer(&a[0]))
bw := (*[2]uintptr)(unsafe.Pointer(&b[0]))
dw[0] = aw[0] ^ bw[0]
dw[1] = aw[1] ^ bw[1]
}