summaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-02-03 12:59:28 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-02-03 12:59:28 -0400
commit67078adb077257c81270f7e17064f0b40919d3de (patch)
tree2ce3b0d817e3f24e14ada5ea4c9a180fa4c58b07 /Annex
parent609d9433a02853a8fea15713f76a95e9b6eed3a7 (diff)
avoid unnecessary building of a one-off Map
A case lookup should be more efficient.
Diffstat (limited to 'Annex')
-rw-r--r--Annex/FileMatcher.hs40
1 files changed, 20 insertions, 20 deletions
diff --git a/Annex/FileMatcher.hs b/Annex/FileMatcher.hs
index 4c7541b46..fba26a898 100644
--- a/Annex/FileMatcher.hs
+++ b/Annex/FileMatcher.hs
@@ -74,26 +74,26 @@ exprParser matchstandard matchgroupwanted getgroupmap configmap mu expr =
parseToken :: FileMatcher Annex -> FileMatcher Annex -> MkLimit Annex -> MkLimit Annex -> Annex GroupMap -> String -> Either String (Token (MatchFiles Annex))
parseToken matchstandard matchgroupwanted checkpresent checkpreferreddir getgroupmap t
| t `elem` tokens = Right $ token t
- | t == "standard" = call matchstandard
- | t == "groupwanted" = call matchgroupwanted
- | t == "present" = use checkpresent
- | t == "inpreferreddir" = use checkpreferreddir
- | t == "unused" = Right $ Operation limitUnused
- | t == "anything" = Right $ Operation limitAnything
- | t == "nothing" = Right $ Operation limitNothing
- | otherwise = maybe (Left $ "near " ++ show t) use $ M.lookup k $
- M.fromList
- [ ("include", limitInclude)
- , ("exclude", limitExclude)
- , ("copies", limitCopies)
- , ("lackingcopies", limitLackingCopies False)
- , ("approxlackingcopies", limitLackingCopies True)
- , ("inbackend", limitInBackend)
- , ("largerthan", limitSize (>))
- , ("smallerthan", limitSize (<))
- , ("metadata", limitMetaData)
- , ("inallgroup", limitInAllGroup getgroupmap)
- ]
+ | otherwise = case t of
+ "standard" -> call matchstandard
+ "groupwanted" -> call matchgroupwanted
+ "present" -> use checkpresent
+ "inpreferreddir" -> use checkpreferreddir
+ "unused" -> Right $ Operation limitUnused
+ "anything" -> Right $ Operation limitAnything
+ "nothing" -> Right $ Operation limitNothing
+ _ -> case k of
+ "include" -> use limitInclude
+ "exclude" -> use limitExclude
+ "copies" -> use limitCopies
+ "lackingcopies" -> use $ limitLackingCopies False
+ "approxlackingcopies" -> use $ limitLackingCopies True
+ "inbackend" -> use limitInBackend
+ "largerthan" -> use $ limitSize (>)
+ "smallerthan" -> use $ limitSize (<)
+ "metadata" -> use limitMetaData
+ "inallgroup" -> use $ limitInAllGroup getgroupmap
+ _ -> Left $ "near " ++ show t
where
(k, v) = separate (== '=') t
use a = Operation <$> a v