mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 11:07:46 +00:00
runtime/strings: add implementation of strings.IndexByte() (#155)
Signed-off-by: Ron Evans <ron@hybridgroup.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user