github.com/primecitizens/pcz/std@v0.2.1/core/bytealg/index_ppc64x.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 //go:build pcz && (ppc64 || ppc64le) 5 6 package bytealg 7 8 import ( 9 "github.com/primecitizens/pcz/std/core/cpu" 10 ) 11 12 const ( 13 MaxBruteForce = 16 14 15 // indexArgBMaxLen is the maximum length of the string to be searched for (argument b) in Index. 16 // If indexArgBMaxLen is not 0, make sure indexArgBMaxLen >= 4. 17 indexArgBMaxLen = 32 18 ) 19 20 var ( 21 isPOWER9 bool 22 ) 23 24 func init() { 25 isPOWER9 = cpu.PPC64.HasAll(PPC64Feature_is_power9) 26 } 27 28 // cutover reports the number of failures of IndexByte we should tolerate 29 // before switching over to Index. 30 // n is the number of bytes processed so far. 31 // See the bytes.Index implementation for details. 32 func cutover(n int) int { 33 // 1 error per 8 characters, plus a few slop to start. 34 return (n + 16) / 8 35 }