encoding/xml: remove unnecessary memory allocation in Unmarshal
benchmark old ns/op new ns/op delta
BenchmarkUnmarshal 75256 72626 -3.49%
benchmark old allocs new allocs delta
BenchmarkUnmarshal 259 219 -15.44%
Change-Id: I7fd30739b045e35b95e6ef6a8ef2f15b0dd6839c
Reviewed-on: https://go-review.googlesource.com/2758
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/src/encoding/xml/marshal_test.go b/src/encoding/xml/marshal_test.go
index 14f73a7..cdd52ff 100644
--- a/src/encoding/xml/marshal_test.go
+++ b/src/encoding/xml/marshal_test.go
@@ -1148,12 +1148,14 @@
}
func BenchmarkMarshal(b *testing.B) {
+ b.ReportAllocs()
for i := 0; i < b.N; i++ {
Marshal(atomValue)
}
}
func BenchmarkUnmarshal(b *testing.B) {
+ b.ReportAllocs()
xml := []byte(atomXml)
for i := 0; i < b.N; i++ {
Unmarshal(xml, &Feed{})