mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-30 21:26:33 -05:00
refine kcp output
This commit is contained in:
parent
14bbb58b12
commit
3643dc37e0
@ -28,8 +28,7 @@ func (v *SimpleSegmentWriter) Write(seg Segment) error {
|
|||||||
v.Lock()
|
v.Lock()
|
||||||
defer v.Unlock()
|
defer v.Unlock()
|
||||||
|
|
||||||
v.buffer.AppendSupplier(seg.Bytes())
|
v.buffer.Reset(seg.Bytes())
|
||||||
_, err := v.writer.Write(v.buffer.Bytes())
|
_, err := v.writer.Write(v.buffer.Bytes())
|
||||||
v.buffer.Clear()
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -61,12 +61,13 @@ func (v *DataSegment) Command() Command {
|
|||||||
return CommandData
|
return CommandData
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *DataSegment) SetData(b []byte) {
|
func (v *DataSegment) SetData(data []byte) {
|
||||||
if v.Data == nil {
|
if v.Data == nil {
|
||||||
v.Data = buf.NewSmall()
|
v.Data = buf.NewSmall()
|
||||||
}
|
}
|
||||||
v.Data.Clear()
|
v.Data.Reset(func(b []byte) (int, error) {
|
||||||
v.Data.Append(b)
|
return copy(b, data), nil
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *DataSegment) Bytes() buf.Supplier {
|
func (v *DataSegment) Bytes() buf.Supplier {
|
||||||
|
Loading…
Reference in New Issue
Block a user