Debian Codegraph @

libgo/go/internal/bytealg/index_amd64.go

raw
1 // Copyright 2018 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 //go:build ignore_for_gccgo
6 // +build ignore_for_gccgo
7
8 package bytealg
9
10 import "internal/cpu"
11
12 const MaxBruteForce = 64
13
14 func init() {
15 if cpu.X86.HasAVX2 {
16 MaxLen = 63
17 } else {
18 MaxLen = 31
19 }
20 }
21
22 // Cutover reports the number of failures of IndexByte we should tolerate
23 // before switching over to Index.
24 // n is the number of bytes processed so far.
25 // See the bytes.Index implementation for details.
26 func Cutover(n int) int {
27 // 1 error per 8 characters, plus a few slop to start.
28 return (n + 16) / 8
29 }