From 38098954f4165eb15a2868e4acbc0c0045cf2e5c Mon Sep 17 00:00:00 2001 From: Lucas Clemente Date: Tue, 12 Jul 2016 15:01:14 +0200 Subject: [PATCH] reduce calls to framer.getFCAllowance --- stream_framer.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/stream_framer.go b/stream_framer.go index 178c0be6c..0b277af0a 100644 --- a/stream_framer.go +++ b/stream_framer.go @@ -145,11 +145,13 @@ func (f *streamFramer) maybePopNormalFrame(maxBytes protocol.ByteCount) (*frames } maxLen := maxBytes - frameHeaderBytes - fcAllowance, err := f.getFCAllowanceForStream(s) - if err != nil { - return nil, err + if s.lenOfDataForWriting() != 0 { + fcAllowance, err := f.getFCAllowanceForStream(s) + if err != nil { + return nil, err + } + maxLen = utils.MinByteCount(maxLen, fcAllowance) } - maxLen = utils.MinByteCount(maxLen, fcAllowance) if maxLen == 0 { continue