Skip to content

Commit

Permalink
avoid binary.Write when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
qmuntal committed Oct 31, 2020
1 parent 3e49166 commit 5b79d3c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions encode.go
Expand Up @@ -131,11 +131,12 @@ func (e *Encoder) encodeBinary(doc *Document) error {
if err != nil {
return err
}
binary.Write(e.w, binary.LittleEndian, jsonText)
binary.Write(e.w, binary.LittleEndian, headerPadding)
e.w.Write(jsonText)
e.w.Write(headerPadding)
binary.Write(e.w, binary.LittleEndian, &binHeader)
if binBuffer != nil {
binary.Write(e.w, binary.LittleEndian, binBuffer.Data)
e.w.Write(binBuffer.Data)
}
return binary.Write(e.w, binary.LittleEndian, binPadding)
_, err = e.w.Write(binPadding)
return err
}

0 comments on commit 5b79d3c

Please sign in to comment.