mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-08 13:03:39 +00:00
internal/bytealg: reimplement bytealg in pure Go
Previously, we implemented individual bytealg functions via linknaming, and had to update them every once in a while when we hit linker errors. Instead, this change reimplements the bytealg package in pure Go. If something is missing, it will cause a compiler error rather than a linker error. This is easier to test and maintain.
This commit is contained in:
@@ -204,15 +204,3 @@ func decodeUTF8(s string, index uintptr) (rune, uintptr) {
|
||||
return 0xfffd, 1
|
||||
}
|
||||
}
|
||||
|
||||
// indexByteString returns the index of the first instance of c in s, or -1 if c
|
||||
// is not present in s.
|
||||
//go:linkname indexByteString internal/bytealg.IndexByteString
|
||||
func indexByteString(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