From 2f868db90c7ba16eee901b9b1472b1e1a889dd93 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 24 Feb 2017 15:16:56 -0400 Subject: add KeyVariety type Where before the "name" of a key and a backend was a string, this makes it a concrete data type. This is groundwork for allowing some varieties of keys to be disabled in file2key, so git-annex won't use them at all. Benchmarks ran in my big repo: old git-annex info: real 0m3.338s user 0m3.124s sys 0m0.244s new git-annex info: real 0m3.216s user 0m3.024s sys 0m0.220s new git-annex find: real 0m7.138s user 0m6.924s sys 0m0.252s old git-annex find: real 0m7.433s user 0m7.240s sys 0m0.232s Surprising result; I'd have expected it to be slower since it now parses all the key varieties. But, the parser is very simple and perhaps sharing KeyVarieties uses less memory or something like that. This commit was supported by the NSF-funded DataLad project. --- Test.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Test.hs') diff --git a/Test.hs b/Test.hs index 1b724b5af..7ef0cb5f0 100644 --- a/Test.hs +++ b/Test.hs @@ -64,6 +64,7 @@ import qualified Logs.PreferredContent import qualified Types.MetaData import qualified Remote import qualified Key +import qualified Types.Key import qualified Types.Messages import qualified Config import qualified Config.Cost @@ -2152,7 +2153,7 @@ backendWORM :: Types.Backend backendWORM = backend_ "WORM" backend_ :: String -> Types.Backend -backend_ = Backend.lookupBackendName +backend_ = Backend.lookupBackendVariety . Types.Key.parseKeyVariety getKey :: Types.Backend -> FilePath -> IO Types.Key getKey b f = fromJust <$> annexeval go -- cgit v1.2.3