| 1 |
//go:build amd64 |
| 2 |
|
| 3 |
package algo |
| 4 |
|
| 5 |
var _useAVX2 bool |
| 6 |
|
| 7 |
func init() { |
| 8 |
_useAVX2 = cpuHasAVX2() |
| 9 |
} |
| 10 |
|
| 11 |
//go:noescape |
| 12 |
func cpuHasAVX2() bool |
| 13 |
|
| 14 |
// indexByteTwo returns the index of the first occurrence of b1 or b2 in s, |
| 15 |
// or -1 if neither is present. Uses AVX2 when available, SSE2 otherwise. |
| 16 |
// |
| 17 |
//go:noescape |
| 18 |
func IndexByteTwo(s []byte, b1, b2 byte) int |
| 19 |
|
| 20 |
// lastIndexByteTwo returns the index of the last occurrence of b1 or b2 in s, |
| 21 |
// or -1 if neither is present. Uses AVX2 when available, SSE2 otherwise. |
| 22 |
// |
| 23 |
//go:noescape |
| 24 |
func lastIndexByteTwo(s []byte, b1, b2 byte) int |