mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
strings: use runtime assembly for IndexByte
Fixes #3751 R=golang-dev, khr CC=golang-dev https://golang.org/cl/12483043
This commit is contained in:
parent
8ce8adbe7a
commit
598c78967f
6 changed files with 75 additions and 15 deletions
|
|
@ -160,16 +160,6 @@ func Index(s, sep string) int {
|
|||
return -1
|
||||
}
|
||||
|
||||
// IndexByte returns the index of the first instance of c in s, or -1 if c is not present in s.
|
||||
func IndexByte(s string, c byte) int {
|
||||
for i := 0; i < len(s); i++ {
|
||||
if s[i] == c {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// LastIndex returns the index of the last instance of sep in s, or -1 if sep is not present in s.
|
||||
func LastIndex(s, sep string) int {
|
||||
n := len(sep)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue