github.com/guyezi/gofrontend@v0.0.0-20200228202240-7a62a49e62c0/libgo/go/internal/bytealg/index_arm64.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 // Empirical data shows that using Index can get better 10 // performance when len(s) <= 16. 11 const MaxBruteForce = 16 12 13 func init() { 14 // Optimize cases where the length of the substring is less than 32 bytes 15 MaxLen = 32 16 } 17 18 // Cutover reports the number of failures of IndexByte we should tolerate 19 // before switching over to Index. 20 // n is the number of bytes processed so far. 21 // See the bytes.Index implementation for details. 22 func Cutover(n int) int { 23 // 1 error per 16 characters, plus a few slop to start. 24 return 4 + n>>4 25 }