forked from quic-go/quic-go
minor stream optimization
This commit is contained in:
@@ -169,8 +169,8 @@ func (s *stream) lenOfDataForWriting() protocol.ByteCount {
|
|||||||
|
|
||||||
func (s *stream) getDataForWriting(maxBytes protocol.ByteCount) []byte {
|
func (s *stream) getDataForWriting(maxBytes protocol.ByteCount) []byte {
|
||||||
s.mutex.Lock()
|
s.mutex.Lock()
|
||||||
defer s.mutex.Unlock()
|
|
||||||
if s.dataForWriting == nil {
|
if s.dataForWriting == nil {
|
||||||
|
s.mutex.Unlock()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var ret []byte
|
var ret []byte
|
||||||
@@ -183,6 +183,7 @@ func (s *stream) getDataForWriting(maxBytes protocol.ByteCount) []byte {
|
|||||||
s.doneWritingOrErrCond.Signal()
|
s.doneWritingOrErrCond.Signal()
|
||||||
}
|
}
|
||||||
s.writeOffset += protocol.ByteCount(len(ret))
|
s.writeOffset += protocol.ByteCount(len(ret))
|
||||||
|
s.mutex.Unlock()
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user