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

@ -1,22 +1,33 @@
{- git-annex repo groups
-
- Copyright 2012 Joey Hess <id@joeyh.name>
- Copyright 2012, 2019 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Types.Group (
Group,
Group(..),
fromGroup,
toGroup,
GroupMap(..),
emptyGroupMap
) where
import Types.UUID
import Utility.FileSystemEncoding
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.ByteString as S
type Group = String
newtype Group = Group S.ByteString
deriving (Eq, Ord)
fromGroup :: Group -> String
fromGroup (Group g) = decodeBS g
toGroup :: String -> Group
toGroup = Group . encodeBS
data GroupMap = GroupMap
{ groupsByUUID :: M.Map UUID (S.Set Group)