optimise getUUID
This avoids a Map lookup each time it's called, instead the GitConfig field lazily looks it up once and then caches.
This commit is contained in:
parent
737e45156e
commit
23ff58cd4f
2 changed files with 14 additions and 5 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue