mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 04:07:35 +03:00
simplify content storage in packed packets
It's not necessary to store both the packetBuffer and the slice containing the raw data in the packet.
This commit is contained in:
parent
077504f557
commit
d642bf9098
10 changed files with 112 additions and 103 deletions
|
@ -15,14 +15,11 @@ var _ = Describe("Send Queue", func() {
|
|||
q = newSendQueue(c)
|
||||
})
|
||||
|
||||
getPacket := func(b []byte) *packedPacket {
|
||||
getPacket := func(b []byte) *packetBuffer {
|
||||
buf := getPacketBuffer()
|
||||
buf.Slice = buf.Slice[:len(b)]
|
||||
copy(buf.Slice, b)
|
||||
return &packedPacket{
|
||||
buffer: buf,
|
||||
raw: buf.Slice,
|
||||
}
|
||||
buf.Data = buf.Data[:len(b)]
|
||||
copy(buf.Data, b)
|
||||
return buf
|
||||
}
|
||||
|
||||
It("sends a packet", func() {
|
||||
|
@ -30,7 +27,7 @@ var _ = Describe("Send Queue", func() {
|
|||
q.Send(p)
|
||||
|
||||
written := make(chan struct{})
|
||||
c.EXPECT().Write(p.raw).Do(func([]byte) { close(written) })
|
||||
c.EXPECT().Write([]byte("foobar")).Do(func([]byte) { close(written) })
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer GinkgoRecover()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue