forked from quic-go/quic-go
speed up marshaling of transport parameters (#3531)
The speedup comes from multiple sources: 1. We now preallocate a byte slice, instead of appending multiple times. 2. Marshaling into a byte slice is faster than using a bytes.Buffer. 3. quicvarint.Write allocates, while quicvarint.Append doesn't.
This commit is contained in:
@@ -51,10 +51,9 @@ func fuzzTransportParametersForSessionTicket(data []byte) int {
|
||||
if err := tp.UnmarshalFromSessionTicket(bytes.NewReader(data)); err != nil {
|
||||
return 0
|
||||
}
|
||||
buf := &bytes.Buffer{}
|
||||
tp.MarshalForSessionTicket(buf)
|
||||
b := tp.MarshalForSessionTicket(nil)
|
||||
tp2 := &wire.TransportParameters{}
|
||||
if err := tp2.UnmarshalFromSessionTicket(bytes.NewReader(buf.Bytes())); err != nil {
|
||||
if err := tp2.UnmarshalFromSessionTicket(bytes.NewReader(b)); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user