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
|
- License: BSD-2-clause
|
||||||
-}
|
-}
|
||||||
|
|
||||||
{-# LANGUAGE TypeSynonymInstances #-}
|
{-# LANGUAGE TypeSynonymInstances, BangPatterns #-}
|
||||||
|
|
||||||
module Utility.Metered where
|
module Utility.Metered where
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ meteredWrite' meterupdate h = go zeroBytesProcessed . L.toChunks
|
||||||
go sofar [] = return sofar
|
go sofar [] = return sofar
|
||||||
go sofar (c:cs) = do
|
go sofar (c:cs) = do
|
||||||
S.hPut h c
|
S.hPut h c
|
||||||
let sofar' = addBytesProcessed sofar $ S.length c
|
let !sofar' = addBytesProcessed sofar $ S.length c
|
||||||
meterupdate sofar'
|
meterupdate sofar'
|
||||||
go sofar' cs
|
go sofar' cs
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ hGetMetered h wantsize meterupdate = lazyRead zeroBytesProcessed
|
||||||
hClose h
|
hClose h
|
||||||
return $ L.empty
|
return $ L.empty
|
||||||
else do
|
else do
|
||||||
let sofar' = addBytesProcessed sofar (S.length c)
|
let !sofar' = addBytesProcessed sofar (S.length c)
|
||||||
meterupdate sofar'
|
meterupdate sofar'
|
||||||
if keepgoing (fromBytesProcessed sofar')
|
if keepgoing (fromBytesProcessed sofar')
|
||||||
then do
|
then do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue