internal/core/convert: use strings.ToValidUTF8 over x/text/encoding/unicode
The former is in the standard library since Go 1.13, it's simpler,
and most importantly, it doesn't allocate in the common case
where the input string is already valid UTF-8.
This is not unexpected; x/text/encoding/unicode has way more features,
so it's much harder for it to do nothing in the happy path.
│ old │ new │
│ B/op │ B/op vs base │
VetInventory 4.687Gi ± ∞ ¹ 4.627Gi ± ∞ ¹ -1.28% (p=1.000 n=1)
│ old │ new │
│ allocs/op │ allocs/op vs base │
VetInventory 49.86M ± ∞ ¹ 49.61M ± ∞ ¹ -0.50% (p=1.000 n=1)
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I8f08a553a84315f851a6d7dabf4e6c379bdaa50a
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1229428
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Matthew Sackman <matthew@cue.works>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>