Speed up the 'unused' command.

Instead of populating the second-level Bloom filter with every key
referenced in every Git reference, consider only those which differ
from what's referenced in the index.

Incidentaly, unlike with its old behavior, staged
modifications/deletion/... will now be detected by 'unused'.

Credits to joeyh for the algorithm. :-)
This commit is contained in:
guilhem 2013-08-26 02:47:49 +02:00 committed by Joey Hess
parent 2794f4fb48
commit f15fda60ed
4 changed files with 32 additions and 26 deletions

View file

@ -8,7 +8,7 @@
module Utility.Monad where
import Data.Maybe
import Control.Monad (liftM)
import Control.Monad
{- Return the first value from a list, if any, satisfying the given
- predicate -}
@ -53,6 +53,16 @@ ma <&&> mb = ifM ma ( mb , return False )
infixr 3 <&&>
infixr 2 <||>
{- Left-to-right Kleisli composition with a pure left/right hand side. -}
(*>=>) :: Monad m => (a -> b) -> (b -> m c) -> (a -> m c)
f *>=> g = return . f >=> g
(>=*>) :: Monad m => (a -> m b) -> (b -> c) -> (a -> m c)
f >=*> g = f >=> return . g
{- Same fixity as >=> and <=< -}
infixr 1 *>=>, >=*>
{- Runs an action, passing its value to an observer before returning it. -}
observe :: Monad m => (a -> m b) -> m a -> m a
observe observer a = do