Skip to content

Commit

Permalink
manually inline writeInt
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg Kovalov <[email protected]>
  • Loading branch information
cristaloleg committed Jun 8, 2021
1 parent b39828b commit 652508d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,20 @@ func (e *Encoder) writeInt(n int64) {
}

func (e *Encoder) marshalBytes(b []byte) {
e.writeInt(int64(len(b)))
e.buf.WriteByte(':')
// manual inline of writeInt
var bs [20]byte // max_str_len( math.MaxInt64, math.MinInt64 ) base 10
buf := strconv.AppendInt(bs[0:0], int64(len(b)), 10)
buf = append(buf, ':')
e.buf.Write(buf)
e.buf.Write(b)
}

func (e *Encoder) marshalString(s string) {
e.writeInt(int64(len(s)))
e.buf.WriteByte(':')
// manual inline of writeInt
var bs [20]byte // max_str_len( math.MaxInt64, math.MinInt64 ) base 10
buf := strconv.AppendInt(bs[0:0], int64(len(s)), 10)
buf = append(buf, ':')
e.buf.Write(buf)
e.buf.WriteString(s)
}

Expand Down

0 comments on commit 652508d

Please sign in to comment.