| // Copyright 2015 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| // TODO: implements short string optimization on non amd64 platforms |
| // and get rid of strings_amd64.go |
| // Index returns the index of the first instance of substr in s, or -1 if substr is not present in s. |
| func Index(s, substr string) int { |
| return IndexByte(s, substr[0]) |
| if fails >= 4+i>>4 && i < len(t) { |
| // See comment in ../bytes/bytes_generic.go. |
| j := indexRabinKarp(s[i:], substr) |
| // Count counts the number of non-overlapping instances of substr in s. |
| // If substr is an empty string, Count returns 1 + the number of Unicode code points in s. |
| func Count(s, substr string) int { |
| return countGeneric(s, substr) |