This can get rid of a bounds check.
Followup to CL 622240.
Change-Id: I9d0a2c0408b8d274c46136d32d7a5fb09b4aad1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/622955
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
c = 2 * cap(b)
}
b2 := append([]byte(nil), make([]byte, c)...)
- copy(b2, b)
- return b2[:len(b)]
+ i := copy(b2, b)
+ return b2[:i]
}
// WriteTo writes data to w until the buffer is drained or an error occurs.
}
s, b := rawstringtmp(buf, l)
for _, x := range a {
- copy(b, x)
- b = b[len(x):]
+ n := copy(b, x)
+ b = b[n:]
}
return s
}