Skip to content

Commit 46eb1c8

Browse files
Update ReadWireMessage to reuse allocated slice
Change-Id: I82bc674e7fcc2031daa8541abb592d96210d0434
1 parent e608edc commit 46eb1c8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core/connection/connection.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ func (c *connection) ReadWireMessage(ctx context.Context) (wiremessage.WireMessa
699699

700700
// Isn't the best reuse, but resizing a []byte to be larger
701701
// is difficult.
702-
if len(c.readBuf) > int(size) {
702+
if cap(c.readBuf) > int(size) {
703703
c.readBuf = c.readBuf[:size]
704704
} else {
705705
c.readBuf = make([]byte, size)

0 commit comments

Comments
 (0)