Skip to content

Commit c16fce9

Browse files
committed
common/bitutil: using subtle.XORBytes for optimization
1 parent 5d51208 commit c16fce9

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

common/bitutil/bitutil.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
package bitutil
99

1010
import (
11+
"crypto/subtle"
1112
"runtime"
1213
"unsafe"
1314
)
@@ -18,10 +19,7 @@ const supportsUnaligned = runtime.GOARCH == "386" || runtime.GOARCH == "amd64" |
1819
// XORBytes xors the bytes in a and b. The destination is assumed to have enough
1920
// space. Returns the number of bytes xor'd.
2021
func XORBytes(dst, a, b []byte) int {
21-
if supportsUnaligned {
22-
return fastXORBytes(dst, a, b)
23-
}
24-
return safeXORBytes(dst, a, b)
22+
return subtle.XORBytes(dst, a, b)
2523
}
2624

2725
// fastXORBytes xors in bulk. It only works on architectures that support

0 commit comments

Comments
 (0)