github.com/fisco-bcos/crypto@v0.0.0-20200202032121-bd8ab0b5d4f1/internal/bytealg/index_s390x.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 package bytealg 6 7 import "internal/cpu" 8 9 const MaxBruteForce = 64 10 11 func init() { 12 // Note: we're kind of lucky that this flag is available at this point. 13 // The runtime sets HasVX when processing auxv records, and that happens 14 // to happen *before* running the init functions of packages that 15 // the runtime depends on. 16 // TODO: it would really be nicer for internal/cpu to figure out this 17 // flag by itself. Then we wouldn't need to depend on quirks of 18 // early startup initialization order. 19 if cpu.S390X.HasVX { 20 MaxLen = 64 21 } 22 } 23 24 // Cutover reports the number of failures of IndexByte we should tolerate 25 // before switching over to Index. 26 // n is the number of bytes processed so far. 27 // See the bytes.Index implementation for details. 28 func Cutover(n int) int { 29 // 1 error per 8 characters, plus a few slop to start. 30 return (n + 16) / 8 31 }