From 65f245af49995becc2d5321eb3e97a243d647e1f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Mart=C3=AD?= Date: Thu, 7 Sep 2023 10:29:14 +0100 Subject: [PATCH] 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 LUCI-TryBot-Result: Go LUCI Reviewed-by: Ian Lance Taylor Reviewed-by: Matthew Dempsky --- src/encoding/xml/marshal.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encoding/xml/marshal.go b/src/encoding/xml/marshal.go index c93e35222d..5cf12f0888 100644 --- a/src/encoding/xml/marshal.go +++ b/src/encoding/xml/marshal.go @@ -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) -- 2.50.0