diff options
author | Joey Hess <joeyh@joeyh.name> | 2019-11-27 16:54:11 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2019-11-27 17:40:09 -0400 |
commit | d7833def6620f2cdc3971eab38f3620e050404fb (patch) | |
tree | 1383373bfa3cdf112b3747c3d5f9ec8f9e38ae41 /Types/Difference.hs | |
parent | 37d0f73e66588dd77b5c07b69a1d6aa3ce71eb05 (diff) |
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.
Diffstat (limited to 'Types/Difference.hs')
-rw-r--r-- | Types/Difference.hs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Types/Difference.hs b/Types/Difference.hs index 774336c18e..678b6f4bf6 100644 --- a/Types/Difference.hs +++ b/Types/Difference.hs @@ -5,6 +5,8 @@ - Licensed under the GNU AGPL version 3 or higher. -} +{-# LANGUAGE OverloadedStrings #-} + module Types.Difference ( Difference(..), Differences(..), @@ -23,6 +25,7 @@ import qualified Git.Config import Data.Maybe import Data.Monoid +import qualified Data.ByteString as B import qualified Data.Set as S import qualified Data.Semigroup as Sem import Prelude @@ -92,11 +95,11 @@ getDifferences :: Git.Repo -> Differences getDifferences r = mkDifferences $ S.fromList $ mapMaybe getmaybe [minBound .. maxBound] where - getmaybe d = case Git.Config.isTrue =<< Git.Config.getMaybe (differenceConfigKey d) r of + getmaybe d = case Git.Config.isTrue' =<< Git.Config.getMaybe (differenceConfigKey d) r of Just True -> Just d _ -> Nothing -differenceConfigKey :: Difference -> String +differenceConfigKey :: Difference -> B.ByteString differenceConfigKey ObjectHashLower = tunable "objecthashlower" differenceConfigKey OneLevelObjectHash = tunable "objecthash1" differenceConfigKey OneLevelBranchHash = tunable "branchhash1" @@ -104,8 +107,8 @@ differenceConfigKey OneLevelBranchHash = tunable "branchhash1" differenceConfigVal :: Difference -> String differenceConfigVal _ = Git.Config.boolConfig True -tunable :: String -> String -tunable k = "annex.tune." ++ k +tunable :: B.ByteString -> B.ByteString +tunable k = "annex.tune." <> k hasDifference :: Difference -> Differences -> Bool hasDifference _ UnknownDifferences = False |