Skip to content

Commit 5092f23

Browse files
committed
warp: use 'isMultiline' instead of 'p' and inline 'addLine'
1 parent 4f5890a commit 5092f23

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

warp/Network/Wai/Handler/Warp/Request.hs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -293,16 +293,16 @@ push maxTotalHeaderLength src (THStatus totalLen chunkLen reqLines prepend) bs
293293
0 -> True
294294
1 -> SU.unsafeHead bs == _cr
295295
_ -> False
296-
addEither p =
297-
if p then addChunk else addLine
298-
-- addLine: take the current chunk and add to 'lines' as optimal as possible
299-
addLine len chunk =
300-
let newTotal = currentTotal + len
301-
newLine =
302-
if chunkLen == 0
303-
then chunk
304-
else S.toStrict $ B.toLazyByteString $ prepend $ B.byteString chunk
305-
in THStatus newTotal 0 (reqLines . (newLine:)) id
296+
addEither isMultiline len chunk
297+
| isMultiline = addChunk len chunk
298+
-- addLine: take the current chunk and add to 'lines' as optimal as possible
299+
| otherwise =
300+
let newTotal = currentTotal + len
301+
toBS = S.toStrict . B.toLazyByteString
302+
newLine =
303+
if chunkLen == 0 then chunk else toBS $ prepend $ B.byteString chunk
304+
in THStatus newTotal 0 (reqLines . (newLine:)) id
305+
{-# INLINE addChunk #-}
306306
-- addChunk: take the current chunk and add to 'prepend' as optimal as possible
307307
addChunk len chunk =
308308
let newChunkTotal = chunkLen + len

0 commit comments

Comments
 (0)