newtype Group to ByteString

This may speed up queries for things in groups, due to Eq and Ord being faster.
This commit is contained in:
Joey Hess 2019-01-09 15:00:43 -04:00
parent 3f7fe1d325
commit 6f66b53a30
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
10 changed files with 69 additions and 48 deletions

View file

@ -17,6 +17,7 @@ import Types.StandardGroups
import Types.Group
import qualified Data.Map as M
import qualified Data.ByteString.Lazy as L
import Data.ByteString.Builder
{- Changes the preferred content configuration of a remote. -}
@ -46,13 +47,16 @@ groupPreferredContentSet g val = do
Annex.Branch.change groupPreferredContentLog $
buildGroupPreferredContent
. changeMapLog c g val
. parseMapLog Just Just . decodeBL
. parseGroupPreferredContent
Annex.changeState $ \s -> s { Annex.preferredcontentmap = Nothing }
parseGroupPreferredContent :: L.ByteString -> MapLog Group String
parseGroupPreferredContent = parseMapLog (Just . toGroup) Just . decodeBL
buildGroupPreferredContent :: MapLog Group PreferredContentExpression -> Builder
buildGroupPreferredContent = buildMapLog buildgroup buildexpr
where
buildgroup = byteString . encodeBS
buildgroup (Group g) = byteString g
buildexpr = byteString . encodeBS
preferredContentMapRaw :: Annex (M.Map UUID PreferredContentExpression)
@ -64,5 +68,5 @@ requiredContentMapRaw = simpleMap . parseLog Just . decodeBL
<$> Annex.Branch.get requiredContentLog
groupPreferredContentMapRaw :: Annex (M.Map Group PreferredContentExpression)
groupPreferredContentMapRaw = simpleMap . parseMapLog Just Just . decodeBL
groupPreferredContentMapRaw = simpleMap . parseGroupPreferredContent
<$> Annex.Branch.get groupPreferredContentLog