mirror of https://github.com/v2ray/v2ray-core
remove small buffer pool
parent
aabb9137e1
commit
43dacc3936
|
@ -200,11 +200,6 @@ func (b *Buffer) String() string {
|
||||||
return string(b.Value)
|
return string(b.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSmallBuffer creates a Buffer with 1K bytes of arbitrary content.
|
|
||||||
func NewSmallBuffer() *Buffer {
|
|
||||||
return smallPool.Allocate()
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewBuffer creates a Buffer with 8K bytes of arbitrary content.
|
// NewBuffer creates a Buffer with 8K bytes of arbitrary content.
|
||||||
func NewBuffer() *Buffer {
|
func NewBuffer() *Buffer {
|
||||||
return mediumPool.Allocate()
|
return mediumPool.Allocate()
|
||||||
|
@ -216,10 +211,6 @@ func NewLargeBuffer() *Buffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBufferWithSize(size int) *Buffer {
|
func NewBufferWithSize(size int) *Buffer {
|
||||||
if size <= SmallBufferSize {
|
|
||||||
return NewSmallBuffer()
|
|
||||||
}
|
|
||||||
|
|
||||||
if size <= BufferSize {
|
if size <= BufferSize {
|
||||||
return NewBuffer()
|
return NewBuffer()
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,8 +52,6 @@ func (p *BufferPool) Free(buffer *Buffer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SmallBufferSize = 1600 - defaultOffset
|
|
||||||
|
|
||||||
mediumBufferByteSize = 8 * 1024
|
mediumBufferByteSize = 8 * 1024
|
||||||
BufferSize = mediumBufferByteSize - defaultOffset
|
BufferSize = mediumBufferByteSize - defaultOffset
|
||||||
|
|
||||||
|
@ -64,7 +62,6 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
smallPool = NewBufferPool(1600, 256)
|
|
||||||
mediumPool *BufferPool
|
mediumPool *BufferPool
|
||||||
largePool *BufferPool
|
largePool *BufferPool
|
||||||
)
|
)
|
||||||
|
|
|
@ -126,9 +126,6 @@ func (this *Server) handlerUDPPayload(payload *alloc.Buffer, session *proxy.Sess
|
||||||
func (this *Server) handleConnection(conn internet.Connection) {
|
func (this *Server) handleConnection(conn internet.Connection) {
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
buffer := alloc.NewSmallBuffer()
|
|
||||||
defer buffer.Release()
|
|
||||||
|
|
||||||
timedReader := v2net.NewTimeOutReader(16, conn)
|
timedReader := v2net.NewTimeOutReader(16, conn)
|
||||||
defer timedReader.Release()
|
defer timedReader.Release()
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ func (request Socks5UserPassRequest) AuthDetail() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadUserPassRequest(reader io.Reader) (request Socks5UserPassRequest, err error) {
|
func ReadUserPassRequest(reader io.Reader) (request Socks5UserPassRequest, err error) {
|
||||||
buffer := alloc.NewSmallBuffer()
|
buffer := alloc.NewLocalBuffer(512)
|
||||||
defer buffer.Release()
|
defer buffer.Release()
|
||||||
|
|
||||||
_, err = reader.Read(buffer.Value[0:2])
|
_, err = reader.Read(buffer.Value[0:2])
|
||||||
|
@ -186,7 +186,7 @@ type Socks5Request struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadRequest(reader io.Reader) (request *Socks5Request, err error) {
|
func ReadRequest(reader io.Reader) (request *Socks5Request, err error) {
|
||||||
buffer := alloc.NewSmallBuffer()
|
buffer := alloc.NewLocalBuffer(512)
|
||||||
defer buffer.Release()
|
defer buffer.Release()
|
||||||
|
|
||||||
_, err = io.ReadFull(reader, buffer.Value[:4])
|
_, err = io.ReadFull(reader, buffer.Value[:4])
|
||||||
|
|
Loading…
Reference in New Issue