From b6758e67e0126948b3f53e7cfe7699b3b3076213 Mon Sep 17 00:00:00 2001 From: Lucas Clemente Date: Tue, 26 Jul 2016 17:12:42 +0200 Subject: [PATCH] minor stream optimization --- stream.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stream.go b/stream.go index 57d184b4..a97bacdc 100644 --- a/stream.go +++ b/stream.go @@ -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 }