aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/xml/xml.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2015-01-14 21:32:05 +0300
committerDmitry Vyukov <dvyukov@google.com>2015-01-15 08:45:15 +0000
commit437ec6b313196e603c5935012091e53f4ba66726 (patch)
tree7a8d4ca2613994d6a3ec27f91cd3aee493613743 /src/encoding/xml/xml.go
parenta25af2e99e21fe9011d4057cfab1e0cb0ffb3cdb (diff)
downloadgo-437ec6b313196e603c5935012091e53f4ba66726.tar.xz
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>
Diffstat (limited to 'src/encoding/xml/xml.go')
-rw-r--r--src/encoding/xml/xml.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/encoding/xml/xml.go b/src/encoding/xml/xml.go
index 8c15b98c3a..5690b20256 100644
--- a/src/encoding/xml/xml.go
+++ b/src/encoding/xml/xml.go
@@ -1119,12 +1119,12 @@ func (d *Decoder) name() (s string, ok bool) {
}
// Now we check the characters.
- s = d.buf.String()
- if !isName([]byte(s)) {
- d.err = d.syntaxError("invalid XML name: " + s)
+ b := d.buf.Bytes()
+ if !isName(b) {
+ d.err = d.syntaxError("invalid XML name: " + string(b))
return "", false
}
- return s, true
+ return string(b), true
}
// Read a name and append its bytes to d.buf.