forked from quic-go/quic-go
improve reading of stream frames, increasing transfer speed by ~10%
This commit is contained in:
@@ -3,8 +3,6 @@ package frames
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/protocol"
|
"github.com/lucas-clemente/quic-go/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/qerr"
|
"github.com/lucas-clemente/quic-go/qerr"
|
||||||
@@ -68,13 +66,15 @@ func ParseStreamFrame(r *bytes.Reader) (*StreamFrame, error) {
|
|||||||
|
|
||||||
if dataLen == 0 {
|
if dataLen == 0 {
|
||||||
// The rest of the packet is data
|
// The rest of the packet is data
|
||||||
frame.Data, err = ioutil.ReadAll(r)
|
dataLen = uint16(r.Len())
|
||||||
if err != nil {
|
}
|
||||||
return nil, err
|
if dataLen != 0 {
|
||||||
}
|
|
||||||
} else {
|
|
||||||
frame.Data = make([]byte, dataLen)
|
frame.Data = make([]byte, dataLen)
|
||||||
if _, err := io.ReadFull(r, frame.Data); err != nil {
|
n, err := r.Read(frame.Data)
|
||||||
|
if n != int(dataLen) {
|
||||||
|
return nil, errors.New("BUG: StreamFrame could not read dataLen bytes")
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user