github.com/guyezi/gofrontend@v0.0.0-20200228202240-7a62a49e62c0/libgo/go/internal/bytealg/index_amd64.go (about) 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 // +build ignore_for_gccgo 6 7 package bytealg 8 9 import "internal/cpu" 10 11 const MaxBruteForce = 64 12 13 func init() { 14 if cpu.X86.HasAVX2 { 15 MaxLen = 63 16 } else { 17 MaxLen = 31 18 } 19 } 20 21 // Cutover reports the number of failures of IndexByte we should tolerate 22 // before switching over to Index. 23 // n is the number of bytes processed so far. 24 // See the bytes.Index implementation for details. 25 func Cutover(n int) int { 26 // 1 error per 8 characters, plus a few slop to start. 27 return (n + 16) / 8 28 }