Skip to content

Commit

Permalink
BufferReadUntilBlock should release buf when no bytes read
Browse files Browse the repository at this point in the history
This was causing allocations every time there was a non-blocking read
with nothing to read.

#1481
  • Loading branch information
jackc committed Jan 28, 2023
1 parent f839d50 commit 7941518
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/nbconn/nbconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ func (c *NetConn) BufferReadUntilBlock() error {
if n > 0 {
buf = buf[:n]
c.readQueue.pushBack(buf)
} else if n == 0 {
iobufpool.Put(buf)
}

if err != nil {
Expand Down

0 comments on commit 7941518

Please sign in to comment.