To make code a bit simpler.
Change-Id: I59fca1d5760e304abd53873ecf9ca8b2903e02e8
GitHub-Last-Rev:
1369df6da16121c342a4e678efe3e5b082485b74
GitHub-Pull-Request: golang/go#71873
Reviewed-on: https://go-review.googlesource.com/c/go/+/651355
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
// For now, cast only a small portion of byte slices to a string
// so that it can be stack allocated. This slows down []byte slightly
// due to the extra copy, but keeps string performance roughly the same.
- n := len(src) - i
- if n > utf8.UTFMax {
- n = utf8.UTFMax
- }
+ n := min(len(src)-i, utf8.UTFMax)
c, size := utf8.DecodeRuneInString(string(src[i : i+n]))
if c == utf8.RuneError && size == 1 {
dst = append(dst, src[start:i]...)