]> Cypherpunks repositories - gostls13.git/commit
encoding/xml: avoid an allocation for tags without attributes
authorBrian Smith <ohohvi@gmail.com>
Sat, 7 Feb 2015 03:51:13 +0000 (03:51 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sat, 7 Feb 2015 22:09:03 +0000 (22:09 +0000)
commit8f02df76f962e5ea2daf27108a0c8efed2c8d905
treebc2aca35119ca906af950e0dff2048e046b88d1c
parent3d56fe6d9411ace303b18bf930a0200518886ab6
encoding/xml: avoid an allocation for tags without attributes

Before, an array of size 4 would always be allocated even if a tag
doesn't have any attributes. Now that array is allocated only if
needed.

benchmark              old allocs     new allocs     delta
BenchmarkUnmarshal     191            176            -8.5%

Change-Id: I4d214b228883d0a6e892c0d6eb00dfe2da84c116
Reviewed-on: https://go-review.googlesource.com/4160
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/encoding/xml/xml.go