Different keys can have the same size, so can't make a Set of the sizes.

This version actually runs faster yet, too..
This commit is contained in:
Joey Hess 2011-09-20 20:14:17 -04:00
parent 9f5c7a246b
commit 98fbeba0df

View file

@ -147,14 +147,13 @@ cachedKeysReferenced = do
keySizeSum :: Set Key -> StatState String keySizeSum :: Set Key -> StatState String
keySizeSum s = do keySizeSum s = do
let (sizes, unknownsizes) = S.partition isJust $ S.map keySize s let knownsizes = mapMaybe keySize $ S.toList s
let total = roughSize storageUnits False $ let total = roughSize storageUnits False $ sum knownsizes
fromJust $ S.fold (liftM2 (+)) (Just 0) sizes let missing = S.size s - genericLength knownsizes
let num = S.size unknownsizes
return $ total ++ return $ total ++
if num == 0 if missing == 0
then "" then ""
else aside $ "but " ++ show num ++ " keys have unknown size" else aside $ "but " ++ show missing ++ " keys have unknown size"
staleSize :: String -> (Git.Repo -> FilePath) -> Stat staleSize :: String -> (Git.Repo -> FilePath) -> Stat
staleSize label dirspec = do staleSize label dirspec = do