Skip to content

Commit

Permalink
opt: avoid redundant calls to ResetBuffer()
Browse files Browse the repository at this point in the history
  • Loading branch information
panjf2000 committed Jun 7, 2020
1 parent 37d75cc commit 31c9dda
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ func (cc *BuiltInFrameCodec) Encode(c Conn, buf []byte) ([]byte, error) {
// Decode ...
func (cc *BuiltInFrameCodec) Decode(c Conn) ([]byte, error) {
buf := c.Read()
c.ResetBuffer()
if len(buf) == 0 {
buf = nil
return nil, nil
}
c.ResetBuffer()
return buf, nil
}

Expand Down

0 comments on commit 31c9dda

Please sign in to comment.