1
0
mirror of https://github.com/golang/go synced 2024-11-21 21:14:47 -07:00

undo CL 13004046 / 5db14b33d6ef

Flushing after every token negates the point of buffering. A different approach is required.

««« original CL description
encoding/xml: flush buffer after encoding token

R=rsc, bradfitz, adg
CC=golang-dev
https://golang.org/cl/13004046

»»»

R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/13515043
This commit is contained in:
Rob Pike 2013-09-06 07:54:43 +10:00 committed by Andrew Gerrand
parent 28bbc6c27a
commit 46f96079df
2 changed files with 2 additions and 10 deletions

View File

@ -196,6 +196,7 @@ func (enc *Encoder) EncodeToken(t Token) error {
p.WriteString("<!--")
p.Write(t)
p.WriteString("-->")
return p.cachedWriteError()
case ProcInst:
if t.Target == "xml" || !isNameString(t.Target) {
return fmt.Errorf("xml: EncodeToken of ProcInst with invalid Target")
@ -218,7 +219,7 @@ func (enc *Encoder) EncodeToken(t Token) error {
p.Write(t)
p.WriteString(">")
}
return p.Flush()
return p.cachedWriteError()
}
type printer struct {

View File

@ -1076,15 +1076,6 @@ func TestMarshalWriteIOErrors(t *testing.T) {
}
}
func TestEncodeTokenFlush(t *testing.T) {
var buf bytes.Buffer
enc := NewEncoder(&buf)
enc.EncodeToken(StartElement{Name: Name{Local: "some-tag"}})
if g, w := buf.String(), "<some-tag>"; g != w {
t.Errorf("Encoder wrote %q, want %q", g, w)
}
}
func BenchmarkMarshal(b *testing.B) {
for i := 0; i < b.N; i++ {
Marshal(atomValue)