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

@@ -40,9 +40,9 @@ func (f *StopSendingFrame) Length(_ protocol.VersionNumber) protocol.ByteCount {
return 1 + quicvarint.Len(uint64(f.StreamID)) + quicvarint.Len(uint64(f.ErrorCode))
}
func (f *StopSendingFrame) Write(b *bytes.Buffer, _ protocol.VersionNumber) error {
b.WriteByte(0x5)
quicvarint.Write(b, uint64(f.StreamID))
quicvarint.Write(b, uint64(f.ErrorCode))
return nil
func (f *StopSendingFrame) Write(b []byte, _ protocol.VersionNumber) ([]byte, error) {
b = append(b, 0x5)
b = quicvarint.Append(b, uint64(f.StreamID))
b = quicvarint.Append(b, uint64(f.ErrorCode))
return b, nil
}