1 // Copyright 2015 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 // TODO: implements short string optimization on non amd64 platforms
10 // and get rid of strings_amd64.go
12 // Index returns the index of the first instance of sep in s, or -1 if sep is not present in s.
13 func Index(s
, sep
string) int {
19 return IndexByte(s
, sep
[0])
29 hashsep
, pow
:= hashStr(sep
)
31 for i
:= 0; i
< n
; i
++ {
32 h
= h
*primeRK
+ uint32(s
[i
])
34 if h
== hashsep
&& s
[:n
] == sep
{
37 for i
:= n
; i
< len(s
); {
40 h
-= pow
* uint32(s
[i
-n
])
42 if h
== hashsep
&& s
[i
-n
:i
] == sep
{