Skip to content

Commit

Permalink
perf: round encoder buffer size to nearest sizeclasses (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
muktihari authored Sep 11, 2024
1 parent fd72df2 commit 0616e92
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions encoder/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type Encoder struct {

mesgDef proto.MessageDefinition // Temporary message definition to reduce alloc.

// Dynamic-sized buffer for encoding, starting at 1537 bytes (the maximum size of Message Definition).
// Dynamic-sized buffer for encoding, starting at 1536 bytes (see PR #415 and #416 for details).
// It starts small but grows as needed and may only grow when using Message's MarshalAppend.
buf []byte
}
Expand Down Expand Up @@ -190,7 +190,7 @@ func New(w io.Writer, opts ...Option) *Encoder {
crc16: crc16.New(nil),
protocolValidator: new(proto.Validator),
localMesgNumLRU: new(lru),
buf: make([]byte, 0, proto.MaxBytesPerMessageDefinition),
buf: make([]byte, 0, 1536),
}
e.Reset(w, opts...)
return e
Expand Down

0 comments on commit 0616e92

Please sign in to comment.