github.com/primecitizens/pcz/std@v0.2.1/core/bytealg/index_arm64.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  
     4  //go:build pcz && arm64
     5  
     6  package bytealg
     7  
     8  // Optimize cases where the length of the substring is less than 32 bytes
     9  const (
    10  	// Empirical data shows that using Index can get better
    11  	// performance when len(s) <= 16.
    12  	MaxBruteForce = 16
    13  
    14  	// indexArgBMaxLen is the maximum length of the string to be searched for (argument b) in Index.
    15  	// If indexArgBMaxLen is not 0, make sure indexArgBMaxLen >= 4.
    16  	indexArgBMaxLen = 32
    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 16 characters, plus a few slop to start.
    25  	return 4 + n>>4
    26  }