diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-01-20 16:55:06 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-01-20 16:55:06 -0400 |
commit | 9bb68caba5cf32009f35945e819fba877ec0f438 (patch) | |
tree | 27d9cc159d195374fa95424f186d9ad9c732d514 /Types | |
parent | 10c579282b4f0acc7f26d8084916f7d538a89bd8 (diff) |
optimise getUUID
This avoids a Map lookup each time it's called, instead the GitConfig field
lazily looks it up once and then caches.
Diffstat (limited to 'Types')
-rw-r--r-- | Types/GitConfig.hs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Types/GitConfig.hs b/Types/GitConfig.hs index 0f2e1eaf2..208da4ac7 100644 --- a/Types/GitConfig.hs +++ b/Types/GitConfig.hs @@ -19,6 +19,7 @@ import qualified Git.Construct import Git.SharedRepository import Utility.DataUnits import Config.Cost +import Types.UUID import Types.Distribution import Types.Availability import Types.NumCopies @@ -32,6 +33,7 @@ import Utility.ThreadScheduler (Seconds(..)) - such as annex.foo -} data GitConfig = GitConfig { annexVersion :: Maybe String + , annexUUID :: UUID , annexNumCopies :: Maybe NumCopies , annexDiskReserve :: Integer , annexDirect :: Bool @@ -75,6 +77,7 @@ data GitConfig = GitConfig extractGitConfig :: Git.Repo -> GitConfig extractGitConfig r = GitConfig { annexVersion = notempty $ getmaybe (annex "version") + , annexUUID = maybe NoUUID toUUID $ getmaybe (annex "uuid") , annexNumCopies = NumCopies <$> getmayberead (annex "numcopies") , annexDiskReserve = fromMaybe onemegabyte $ readSize dataUnits =<< getmaybe (annex "diskreserve") |