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