1 // Copyright 2017 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.
9 func countByte(s
[]byte, c
byte) int // bytes_arm64.s
11 // Index returns the index of the first instance of sep in s, or -1 if sep is not present in s.
12 func Index(s
, sep
[]byte) int {
18 return IndexByte(s
, sep
[0])
33 o
:= IndexByte(t
[i
:], c
)
39 if Equal(s
[i
:i
+n
], sep
) {
44 if fails
>= 4+i
>>4 && i
< len(t
) {
45 // Give up on IndexByte, it isn't skipping ahead
46 // far enough to be better than Rabin-Karp.
47 // Experiments (using IndexPeriodic) suggest
48 // the cutover is about 16 byte skips.
49 // TODO: if large prefixes of sep are matching
50 // we should cutover at even larger average skips,
51 // because Equal becomes that much more expensive.
52 // This code does not take that effect into account.
53 j
:= indexRabinKarp(s
[i
:], sep
)
63 // Count counts the number of non-overlapping instances of sep in s.
64 // If sep is an empty slice, Count returns 1 + the number of UTF-8-encoded code points in s.
65 func Count(s
, sep
[]byte) int {
67 return countByte(s
, sep
[0])
69 return countGeneric(s
, sep
)