encoding/xml: use reflect.Value.Bytes on addressable arrays

Since #47066 was accepted and implemented,
reflect.Value.Bytes can be called directly on addressable arrays,
so there is no longer a need to go through a slice first.

Change-Id: I04d50ddb1b38e7a37fee3dc8be1bd03b22a06a1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/526357
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Daniel Martí 2023-09-07 10:29:14 +01:00
parent d80f3966b8
commit 65f245af49
1 changed files with 1 additions and 1 deletions

View File

@ -797,7 +797,7 @@ func (p *printer) marshalSimple(typ reflect.Type, val reflect.Value) (string, []
// [...]byte
var bytes []byte
if val.CanAddr() {
bytes = val.Slice(0, val.Len()).Bytes()
bytes = val.Bytes()
} else {
bytes = make([]byte, val.Len())
reflect.Copy(reflect.ValueOf(bytes), val)