use ByteString for git config
The parser and looking up config keys in the map should both be faster due to using ByteString. I had hoped this would speed up startup time, but any improvement to that was too small to measure. Seems worth keeping though. Note that the parser breaks up the ByteString, but a config map ends up pointing to the config as read, which is retained in memory until every value from it is no longer used. This can change memory usage patterns marginally, but won't affect git-annex.
This commit is contained in:
parent
37d0f73e66
commit
d7833def66
27 changed files with 176 additions and 105 deletions
|
@ -5,6 +5,8 @@
|
|||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Types.GitConfig (
|
||||
Configurable(..),
|
||||
GitConfig(..),
|
||||
|
@ -199,16 +201,17 @@ extractGitConfig r = GitConfig
|
|||
}
|
||||
where
|
||||
getbool k d = fromMaybe d $ getmaybebool k
|
||||
getmaybebool k = Git.Config.isTrue =<< getmaybe k
|
||||
getmaybebool k = Git.Config.isTrue' =<< getmaybe' k
|
||||
getmayberead k = readish =<< getmaybe k
|
||||
getmaybe k = Git.Config.getMaybe k r
|
||||
getlist k = Git.Config.getList k r
|
||||
getmaybe = fmap decodeBS' . getmaybe'
|
||||
getmaybe' k = Git.Config.getMaybe k r
|
||||
getlist k = map decodeBS' $ Git.Config.getList k r
|
||||
getwords k = fromMaybe [] $ words <$> getmaybe k
|
||||
|
||||
configurable d Nothing = DefaultConfig d
|
||||
configurable _ (Just v) = HasConfig v
|
||||
|
||||
annex k = "annex." ++ k
|
||||
annex k = "annex." <> k
|
||||
|
||||
onemegabyte = 1000000
|
||||
|
||||
|
@ -340,14 +343,15 @@ extractRemoteGitConfig r remotename = do
|
|||
}
|
||||
where
|
||||
getbool k d = fromMaybe d $ getmaybebool k
|
||||
getmaybebool k = Git.Config.isTrue =<< getmaybe k
|
||||
getmaybebool k = Git.Config.isTrue' =<< getmaybe' k
|
||||
getmayberead k = readish =<< getmaybe k
|
||||
getmaybe k = mplus (Git.Config.getMaybe (key k) r)
|
||||
getmaybe = fmap decodeBS' . getmaybe'
|
||||
getmaybe' k = mplus (Git.Config.getMaybe (key k) r)
|
||||
(Git.Config.getMaybe (remotekey k) r)
|
||||
getoptions k = fromMaybe [] $ words <$> getmaybe k
|
||||
|
||||
key k = "annex." ++ k
|
||||
remotekey k = "remote." ++ remotename ++ ".annex-" ++ k
|
||||
key k = "annex." <> k
|
||||
remotekey k = "remote." <> encodeBS' remotename <> ".annex-" <> k
|
||||
|
||||
notempty :: Maybe String -> Maybe String
|
||||
notempty Nothing = Nothing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue