Skip to content
This repository has been archived by the owner on Jan 30, 2025. It is now read-only.

Commit

Permalink
Add reuse of the bufio.Reader
Browse files Browse the repository at this point in the history
  • Loading branch information
ankur22 committed Oct 11, 2024
1 parent 6617966 commit 14fbdd8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion common/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ func (c *Connection) recvLoop() {
wsBuffer := make([]byte, 4096)
// This buffer grows as the test progresses.
var recvBuffer []byte
var bufReader bufio.Reader

c.logger.Debugf("Connection:recvLoop", "wsURL:%q", c.wsURL)
for {
Expand All @@ -337,7 +338,7 @@ func (c *Connection) recvLoop() {
}

// Buffered reads from the websocket connection.
bufReader := bufio.NewReader(reader)
bufReader.Reset(reader)
for {
n, err := bufReader.Read(wsBuffer)
if err == io.EOF {
Expand Down

0 comments on commit 14fbdd8

Please sign in to comment.