diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-12-08 16:28:07 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-12-08 16:28:07 -0400 |
commit | a741c897fa77dc596a17a261eb63fc4a2956fdba (patch) | |
tree | e2e6c749160643b30c88d92caaf0fe048fcb83fa | |
parent | 8c41972a6e9bf10a2b0b887a6618a6981d4a3c7e (diff) |
force sofar calculation
This could avoid a memory leak. It would only happen when
the meter didn't look at sofar.
-rw-r--r-- | Utility/Metered.hs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Utility/Metered.hs b/Utility/Metered.hs index b80d3ae3f..e21e18cf1 100644 --- a/Utility/Metered.hs +++ b/Utility/Metered.hs @@ -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 |