summaryrefslogtreecommitdiff
path: root/Command/Status.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-10-07 02:48:39 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-10-07 03:59:14 -0400
commit25dbffe682ba78d0a6dccaa9c64848600e729028 (patch)
tree2d2a61019defd49d35c5868beaab56984ecd9bd4 /Command/Status.hs
parent717b988fd0786943a13be5e1ed20b7ce24890b74 (diff)
status: Fix space leak in local mode, introduced in version 4.20130920.
Actually fixed 2 leaks, the tuple leak may have been older.
Diffstat (limited to 'Command/Status.hs')
-rw-r--r--Command/Status.hs19
1 files changed, 10 insertions, 9 deletions
diff --git a/Command/Status.hs b/Command/Status.hs
index 290ecd586..e9df79eb3 100644
--- a/Command/Status.hs
+++ b/Command/Status.hs
@@ -311,15 +311,16 @@ getLocalStatInfo dir = do
initial = (emptyKeyData, emptyKeyData, emptyNumCopiesStats)
update matcher fast key file vs@(presentdata, referenceddata, numcopiesstats) =
ifM (matcher $ FileInfo file file)
- ( (,,)
- <$> ifM (inAnnex key)
+ ( do
+ !presentdata' <- ifM (inAnnex key)
( return $ addKey key presentdata
, return presentdata
)
- <*> pure (addKey key referenceddata)
- <*> if fast
+ let !referenceddata' = addKey key referenceddata
+ !numcopiesstats' <- if fast
then return numcopiesstats
else updateNumCopiesStats key file numcopiesstats
+ return $! (presentdata', referenceddata', numcopiesstats')
, return vs
)
@@ -345,11 +346,11 @@ addKey key (KeyData count size unknownsize backends) =
ks = keySize key
updateNumCopiesStats :: Key -> FilePath -> NumCopiesStats -> Annex NumCopiesStats
-updateNumCopiesStats key file stats = do
- variance <- Variance <$> numCopiesCheck file key (-)
- return $ stats { numCopiesVarianceMap = update (numCopiesVarianceMap stats) variance }
- where
- update m variance = M.insertWith' (+) variance 1 m
+updateNumCopiesStats key file (NumCopiesStats m) = do
+ !variance <- Variance <$> numCopiesCheck file key (-)
+ let !m' = M.insertWith' (+) variance 1 m
+ let !ret = NumCopiesStats m'
+ return ret
showSizeKeys :: KeyData -> String
showSizeKeys d = total ++ missingnote