theoretical optimisation of --in

Avoids looking up the remote each time, but in practice, does not result in
a measurable speedup.
This commit is contained in:
Joey Hess 2014-03-13 18:51:44 -04:00
parent a6db329117
commit 83ccce68a2

View file

@ -94,18 +94,16 @@ matchGlobFile glob = go
{- Adds a limit to skip files not believed to be present {- Adds a limit to skip files not believed to be present
- in a specfied repository. Optionally on a prior date. -} - in a specfied repository. Optionally on a prior date. -}
addIn :: String -> Annex () addIn :: String -> Annex ()
addIn = addLimit . limitIn addIn s = addLimit =<< mk
limitIn :: MkLimit
limitIn s = Right $ \notpresent -> checkKey $ \key ->
if name == "."
then if null date
then inhere notpresent key
else inuuid notpresent key =<< getUUID
else inuuid notpresent key =<< Remote.nameToUUID name
where where
(name, date) = separate (== '@') s (name, date) = separate (== '@') s
inuuid notpresent key u mk
| name == "." = if null date
then use inhere
else use . inuuid =<< getUUID
| otherwise = use . inuuid =<< Remote.nameToUUID name
use a = return $ Right $ \notpresent -> checkKey (a notpresent)
inuuid u notpresent key
| null date = do | null date = do
us <- Remote.keyLocations key us <- Remote.keyLocations key
return $ u `elem` us && u `S.notMember` notpresent return $ u `elem` us && u `S.notMember` notpresent