chore: direct append data to bufio.Reader's internal buffer as much as possible

This commit is contained in:
wwqgtxx
2023-11-09 22:19:29 +08:00
parent fe7c1a2cdb
commit 832dae3421
3 changed files with 43 additions and 2 deletions

View File

@@ -84,9 +84,9 @@ func (c *BufferedConn) ReadCached() *buf.Buffer { // call in sing/common/bufio.C
length := c.r.Buffered()
b, _ := c.r.Peek(length)
_, _ = c.r.Discard(length)
c.r = nil // drop bufio.Reader to let gc can clean up its internal buf
return buf.As(b)
}
c.r = nil // drop bufio.Reader to let gc can clean up its internal buf
return nil
}