mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-05-14 18:09:05 +00:00
Chore: Use buf.New() instead of buf.NewWithSize() (#5946)
https://github.com/XTLS/Xray-core/pull/5941#issuecomment-4252905907 https://github.com/XTLS/Xray-core/pull/5946#issuecomment-4253919073
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"net"
|
||||
"sync"
|
||||
|
||||
xbuf "github.com/xtls/xray-core/common/buf"
|
||||
"github.com/xtls/xray-core/common/bytespool"
|
||||
"github.com/xtls/xray-core/common/errors"
|
||||
)
|
||||
|
||||
@@ -150,11 +150,10 @@ type headerReadAddrAware interface {
|
||||
func (c *headerManagerConn) ReadFrom(p []byte) (n int, addr net.Addr, err error) {
|
||||
buf := p
|
||||
if len(buf) < UDPSize {
|
||||
b := xbuf.NewWithSize(UDPSize)
|
||||
defer b.Release()
|
||||
b.Resize(0, UDPSize)
|
||||
|
||||
buf = b.Bytes()
|
||||
b := bytespool.Alloc(UDPSize)
|
||||
b = b[:UDPSize]
|
||||
defer bytespool.Free(b)
|
||||
buf = b
|
||||
}
|
||||
|
||||
n, addr, err = c.PacketConn.ReadFrom(buf)
|
||||
|
||||
Reference in New Issue
Block a user