avoid duplicates building up in outManifest
Happened exponentially since commit 1a3c60cc8e
This commit is contained in:
parent
58301e40d2
commit
cb59ec3efc
2 changed files with 30 additions and 17 deletions
|
@ -15,6 +15,7 @@ module Types.GitRemoteAnnex
|
|||
import Types.Key
|
||||
|
||||
import qualified Data.Semigroup as Sem
|
||||
import qualified Data.Set as S
|
||||
|
||||
-- The manifest contains an ordered list of git bundle keys.
|
||||
--
|
||||
|
@ -24,21 +25,21 @@ import qualified Data.Semigroup as Sem
|
|||
data Manifest =
|
||||
Manifest
|
||||
{ inManifest :: [Key]
|
||||
, outManifest :: [Key]
|
||||
, outManifest :: S.Set Key
|
||||
}
|
||||
deriving (Show)
|
||||
|
||||
-- Smart constructor for Manifest. Preserves outManifest invariant.
|
||||
mkManifest
|
||||
:: [Key] -- ^ inManifest
|
||||
-> [Key] -- ^ outManifest
|
||||
-> S.Set Key -- ^ outManifest
|
||||
-> Manifest
|
||||
mkManifest inks outks = Manifest inks (filter (`notElem` inks) outks)
|
||||
mkManifest inks outks = Manifest inks (S.filter (`notElem` inks) outks)
|
||||
|
||||
instance Monoid Manifest where
|
||||
mempty = Manifest [] []
|
||||
mempty = Manifest mempty mempty
|
||||
|
||||
instance Sem.Semigroup Manifest where
|
||||
a <> b = mkManifest
|
||||
(inManifest a <> inManifest b)
|
||||
(outManifest a <> outManifest b)
|
||||
(S.union (outManifest a) (outManifest b))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue