pool: added bufio.Reader pool

This commit is contained in:
nadoo committed 2020-11-03 22:52:50 +08:00
1 parent c15c55fe05
commit 417ac556f7
29 files changed
+188 -168

No files matched your search

+2 -2
View File
@@ -39,8 +39,8 @@ func (pc *PktConn) ReadFrom(b []byte) (int, net.Addr, error) {
// WriteTo implements the necessary function of net.PacketConn.
func (pc *PktConn) WriteTo(b []byte, addr net.Addr) (int, error) {
buf := pool.GetWriteBuffer()
defer pool.PutWriteBuffer(buf)
buf := pool.GetBytesBuffer()
defer pool.PutBytesBuffer(buf)
binary.Write(buf, binary.BigEndian, uint16(len(b)))
buf.Write(b)