mirror of https://github.com/v2ray/v2ray-core
parent
2d4a0f23d5
commit
1ca3bb9750
|
@ -1,8 +1,6 @@
|
|||
package kcp
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"v2ray.com/core/common/buf"
|
||||
"v2ray.com/core/common/serial"
|
||||
)
|
||||
|
@ -40,12 +38,6 @@ const (
|
|||
DataSegmentOverhead = 18
|
||||
)
|
||||
|
||||
var dataSegmentPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
return new(DataSegment)
|
||||
},
|
||||
}
|
||||
|
||||
type DataSegment struct {
|
||||
Conv uint16
|
||||
Option SegmentOption
|
||||
|
@ -59,11 +51,7 @@ type DataSegment struct {
|
|||
}
|
||||
|
||||
func NewDataSegment() *DataSegment {
|
||||
seg := dataSegmentPool.Get().(*DataSegment)
|
||||
seg.Conv = 0
|
||||
seg.timeout = 0
|
||||
seg.transmit = 0
|
||||
return seg
|
||||
return new(DataSegment)
|
||||
}
|
||||
|
||||
func (s *DataSegment) parse(conv uint16, cmd Command, opt SegmentOption, buf []byte) (bool, []byte) {
|
||||
|
@ -135,15 +123,6 @@ func (s *DataSegment) ByteSize() int32 {
|
|||
func (s *DataSegment) Release() {
|
||||
s.payload.Release()
|
||||
s.payload = nil
|
||||
dataSegmentPool.Put(s)
|
||||
}
|
||||
|
||||
var ackSegmentPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
return &AckSegment{
|
||||
NumberList: make([]uint32, 0, 16),
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
type AckSegment struct {
|
||||
|
@ -158,9 +137,7 @@ type AckSegment struct {
|
|||
const ackNumberLimit = 128
|
||||
|
||||
func NewAckSegment() *AckSegment {
|
||||
seg := ackSegmentPool.Get().(*AckSegment)
|
||||
seg.NumberList = seg.NumberList[:0]
|
||||
return seg
|
||||
return new(AckSegment)
|
||||
}
|
||||
|
||||
func (s *AckSegment) parse(conv uint16, cmd Command, opt SegmentOption, buf []byte) (bool, []byte) {
|
||||
|
@ -239,9 +216,7 @@ func (s *AckSegment) Bytes() buf.Supplier {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *AckSegment) Release() {
|
||||
ackSegmentPool.Put(s)
|
||||
}
|
||||
func (s *AckSegment) Release() {}
|
||||
|
||||
type CmdOnlySegment struct {
|
||||
Conv uint16
|
||||
|
|
Loading…
Reference in New Issue