minor stream optimization

This commit is contained in:
Lucas Clemente
2016-07-26 17:12:42 +02:00
parent 3aa8b1bf37
commit b6758e67e0

View File

@@ -169,8 +169,8 @@ func (s *stream) lenOfDataForWriting() protocol.ByteCount {
func (s *stream) getDataForWriting(maxBytes protocol.ByteCount) []byte {
s.mutex.Lock()
defer s.mutex.Unlock()
if s.dataForWriting == nil {
s.mutex.Unlock()
return nil
}
var ret []byte
@@ -183,6 +183,7 @@ func (s *stream) getDataForWriting(maxBytes protocol.ByteCount) []byte {
s.doneWritingOrErrCond.Signal()
}
s.writeOffset += protocol.ByteCount(len(ret))
s.mutex.Unlock()
return ret
}