use pointer to byte slices in the buffer pool

https://staticcheck.io/docs/staticcheck#SA6002 suggests to use pointers
to objects in the sync.Pool.
This commit is contained in:
Marten Seemann 2018-02-21 22:37:08 +08:00
parent d16dea09cc
commit 07b8821ef7
8 changed files with 21 additions and 30 deletions

View file

@ -24,8 +24,9 @@ type packetUnpacker struct {
}
func (u *packetUnpacker) Unpack(headerBinary []byte, hdr *wire.Header, data []byte) (*unpackedPacket, error) {
buf := getPacketBuffer()
defer putPacketBuffer(buf)
buf := *getPacketBuffer()
buf = buf[:0]
defer putPacketBuffer(&buf)
decrypted, encryptionLevel, err := u.aead.Open(buf, data, hdr.PacketNumber, headerBinary)
if err != nil {
// Wrap err in quicError so that public reset is sent by session