avoid nub
authorJoey Hess <joeyh@joeyh.name>
Tue, 15 Jun 2021 14:48:11 +0000 (10:48 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 15 Jun 2021 14:48:11 +0000 (10:48 -0400)
It's O(N^2) which could matter when there are many dup files using the
same key.

Annex/Drop.hs

index 416ce49e949d2d552dc21eda196a52b90eb1e583..da7dad2d198a2bb1be088f3b5d18120840243159 100644 (file)
@@ -55,7 +55,7 @@ handleDropsFrom locs rs reason fromhere key afile si preverified runner = do
        l <- map (`fromTopFilePath` g)
                <$> Database.Keys.getAssociatedFiles key
        let fs = case afile of
-               AssociatedFile (Just f) -> nub (f : l)
+               AssociatedFile (Just f) -> f : filter (/= f) l
                AssociatedFile Nothing -> l
        n <- getcopies fs
        void $ if fromhere && checkcopies n Nothing