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:
Joey Hess 2019-11-27 16:54:11 -04:00
parent 37d0f73e66
commit d7833def66
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
27 changed files with 176 additions and 105 deletions

View file

@ -28,6 +28,7 @@ import System.Posix.User
#endif
import qualified Data.Map as M
import Network.URI
import qualified Data.ByteString as S
import Common
import Git.Types
@ -128,7 +129,7 @@ fromRemotes repo = mapM construct remotepairs
filterconfig f = filter f $ M.toList $ config repo
filterkeys f = filterconfig (\(k,_) -> f k)
remotepairs = filterkeys isRemoteKey
construct (k,v) = remoteNamedFromKey k $ fromRemoteLocation v repo
construct (k,v) = remoteNamedFromKey k (fromRemoteLocation (decodeBS' v) repo)
{- Sets the name of a remote when constructing the Repo to represent it. -}
remoteNamed :: String -> IO Repo -> IO Repo
@ -138,7 +139,7 @@ remoteNamed n constructor = do
{- Sets the name of a remote based on the git config key, such as
- "remote.foo.url". -}
remoteNamedFromKey :: String -> IO Repo -> IO Repo
remoteNamedFromKey :: S.ByteString -> IO Repo -> IO Repo
remoteNamedFromKey = remoteNamed . remoteKeyToRemoteName
{- Constructs a new Repo for one of a Repo's remotes using a given