]>
Commit | Line | Data |
---|---|---|
dd931d9b ILT |
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_gccgo | |
6 | ||
7 | package bytealg | |
8 | ||
aa8901e9 | 9 | // Empirical data shows that using Index can get better |
dd931d9b ILT |
10 | // performance when len(s) <= 16. |
11 | const MaxBruteForce = 16 | |
12 | ||
13 | func init() { | |
14 | // Optimize cases where the length of the substring is less than 32 bytes | |
15 | MaxLen = 32 | |
16 | } | |
17 | ||
18 | // Cutover reports the number of failures of IndexByte we should tolerate | |
aa8901e9 | 19 | // before switching over to Index. |
dd931d9b ILT |
20 | // n is the number of bytes processed so far. |
21 | // See the bytes.Index implementation for details. | |
22 | func Cutover(n int) int { | |
23 | // 1 error per 16 characters, plus a few slop to start. | |
24 | return 4 + n>>4 | |
25 | } |