Skip to content

Commit

Permalink
codec: use a cached 1-byte array for simpleIoEncWriterWriter.WriteByte
Browse files Browse the repository at this point in the history
Fixes #143
  • Loading branch information
ugorji committed Feb 21, 2016
1 parent 9f21f8e commit 03b46f3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion codec/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,16 @@ type simpleIoEncWriterWriter struct {
w io.Writer
bw io.ByteWriter
sw ioEncStringWriter
bs [1]byte
}

func (o *simpleIoEncWriterWriter) WriteByte(c byte) (err error) {
if o.bw != nil {
return o.bw.WriteByte(c)
}
_, err = o.w.Write([]byte{c})
// _, err = o.w.Write([]byte{c})
o.bs[0] = c
_, err = o.w.Write(o.bs[:])
return
}

Expand Down

0 comments on commit 03b46f3

Please sign in to comment.