force sofar calculation
This could avoid a memory leak. It would only happen when the meter didn't look at sofar.
This commit is contained in:
parent
c6972cb914
commit
2ad06ded7e
1 changed files with 3 additions and 3 deletions
|
@ -5,7 +5,7 @@
|
|||
- License: BSD-2-clause
|
||||
-}
|
||||
|
||||
{-# LANGUAGE TypeSynonymInstances #-}
|
||||
{-# LANGUAGE TypeSynonymInstances, BangPatterns #-}
|
||||
|
||||
module Utility.Metered where
|
||||
|
||||
|
@ -93,7 +93,7 @@ meteredWrite' meterupdate h = go zeroBytesProcessed . L.toChunks
|
|||
go sofar [] = return sofar
|
||||
go sofar (c:cs) = do
|
||||
S.hPut h c
|
||||
let sofar' = addBytesProcessed sofar $ S.length c
|
||||
let !sofar' = addBytesProcessed sofar $ S.length c
|
||||
meterupdate sofar'
|
||||
go sofar' cs
|
||||
|
||||
|
@ -138,7 +138,7 @@ hGetMetered h wantsize meterupdate = lazyRead zeroBytesProcessed
|
|||
hClose h
|
||||
return $ L.empty
|
||||
else do
|
||||
let sofar' = addBytesProcessed sofar (S.length c)
|
||||
let !sofar' = addBytesProcessed sofar (S.length c)
|
||||
meterupdate sofar'
|
||||
if keepgoing (fromBytesProcessed sofar')
|
||||
then do
|
||||
|
|
Loading…
Add table
Reference in a new issue