append to a byte slice instead of a bytes.Buffer when serializing frames

This commit is contained in:
Marten Seemann 2022-08-28 23:05:07 +03:00
parent 65dd82ad90
commit 3ca1001951
50 changed files with 443 additions and 425 deletions

View file

@ -20,11 +20,15 @@ func writePacket(hdr *wire.ExtendedHeader, data []byte) []byte {
// packRawPayload returns a new raw payload containing given frames
func packRawPayload(version protocol.VersionNumber, frames []wire.Frame) []byte {
buf := new(bytes.Buffer)
var b []byte
for _, cf := range frames {
cf.Write(buf, version)
var err error
b, err = cf.Write(b, version)
if err != nil {
panic(err)
}
}
return buf.Bytes()
return b
}
// ComposeInitialPacket returns an Initial packet encrypted under key