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:
Jaden Weiss
2020-04-07 17:09:30 -04:00
committed by Ayke
parent 38fc340802
commit 473644d918
6 changed files with 130 additions and 48 deletions
+3 -1
View File
@@ -2,11 +2,13 @@
package runtime
import "internal/bytealg"
// indexByte provides compatibility with Go 1.11.
// See the following:
// https://github.com/tinygo-org/tinygo/issues/351
// https://github.com/golang/go/commit/ad4a58e31501bce5de2aad90a620eaecdc1eecb8
//go:linkname indexByte strings.IndexByte
func indexByte(s string, c byte) int {
return indexByteString(s, c)
return bytealg.IndexByteString(s, c)
}