runtime/strings: add implementation of strings.IndexByte() (#155)

Signed-off-by: Ron Evans <ron@hybridgroup.com>
Этот коммит содержится в:
Ron Evans 2019-01-25 13:44:26 +01:00 коммит произвёл GitHub
родитель 85108514df
коммит d820c36c4f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23

Просмотреть файл

@ -166,3 +166,14 @@ func decodeUTF8(s string, index uintptr) (rune, uintptr) {
return 0xfffd, 1
}
}
// indexByte returns the index of the first instance of c in s, or -1 if c is not present in s.
//go:linkname indexByte strings.IndexByte
func indexByte(s string, c byte) int {
for i := 0; i < len(s); i++ {
if s[i] == c {
return i
}
}
return -1
}