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
|
@ -7,6 +7,8 @@
|
|||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Git.GCrypt where
|
||||
|
||||
import Common
|
||||
|
@ -16,6 +18,8 @@ import qualified Git.Config as Config
|
|||
import qualified Git.Command as Command
|
||||
import Utility.Gpg
|
||||
|
||||
import qualified Data.ByteString as S
|
||||
|
||||
urlScheme :: String
|
||||
urlScheme = "gcrypt:"
|
||||
|
||||
|
@ -75,9 +79,9 @@ type GCryptId = String
|
|||
- which is stored in the repository (in encrypted form)
|
||||
- and cached in a per-remote gcrypt-id configuration setting. -}
|
||||
remoteRepoId :: Repo -> Maybe RemoteName -> Maybe GCryptId
|
||||
remoteRepoId = getRemoteConfig "gcrypt-id"
|
||||
remoteRepoId r n = decodeBS' <$> getRemoteConfig "gcrypt-id" r n
|
||||
|
||||
getRemoteConfig :: String -> Repo -> Maybe RemoteName -> Maybe String
|
||||
getRemoteConfig :: S.ByteString -> Repo -> Maybe RemoteName -> Maybe S.ByteString
|
||||
getRemoteConfig field repo remotename = do
|
||||
n <- remotename
|
||||
Config.getMaybe (remoteConfigKey field n) repo
|
||||
|
@ -93,17 +97,17 @@ getParticiantList globalconfigrepo repo remotename = KeyIds $ parse $ firstJust
|
|||
where
|
||||
defaultkey = "gcrypt.participants"
|
||||
parse (Just "simple") = []
|
||||
parse (Just l) = words l
|
||||
parse (Just b) = words (decodeBS' b)
|
||||
parse Nothing = []
|
||||
|
||||
remoteParticipantConfigKey :: RemoteName -> String
|
||||
remoteParticipantConfigKey :: RemoteName -> S.ByteString
|
||||
remoteParticipantConfigKey = remoteConfigKey "gcrypt-participants"
|
||||
|
||||
remotePublishParticipantConfigKey :: RemoteName -> String
|
||||
remotePublishParticipantConfigKey :: RemoteName -> S.ByteString
|
||||
remotePublishParticipantConfigKey = remoteConfigKey "gcrypt-publish-participants"
|
||||
|
||||
remoteSigningKey :: RemoteName -> String
|
||||
remoteSigningKey :: RemoteName -> S.ByteString
|
||||
remoteSigningKey = remoteConfigKey "gcrypt-signingkey"
|
||||
|
||||
remoteConfigKey :: String -> RemoteName -> String
|
||||
remoteConfigKey key remotename = "remote." ++ remotename ++ "." ++ key
|
||||
remoteConfigKey :: S.ByteString -> RemoteName -> S.ByteString
|
||||
remoteConfigKey key remotename = "remote." <> encodeBS' remotename <> "." <> key
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue