...

Source file src/pkg/internal/bytealg/index_amd64.go

     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		if cpu.X86.HasAVX2 {
    13			MaxLen = 63
    14		} else {
    15			MaxLen = 31
    16		}
    17	}
    18	
    19	// Cutover reports the number of failures of IndexByte we should tolerate
    20	// before switching over to Index.
    21	// n is the number of bytes processed so far.
    22	// See the bytes.Index implementation for details.
    23	func Cutover(n int) int {
    24		// 1 error per 8 characters, plus a few slop to start.
    25		return (n + 16) / 8
    26	}
    27	

View as plain text