1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 17:04:47 +03:00

Compute the absolute difference of a diff as its cost.

This commit is contained in:
Rob Rix 2016-04-12 11:53:51 -04:00
parent d872b5ffff
commit 1d639ce8eb

View File

@ -89,7 +89,7 @@ diffFiles parser renderer sourceBlobs = do
diffCostWithCachedTermSizes :: Diff a Info -> Integer
diffCostWithCachedTermSizes = diffSum (getSum . foldMap (Sum . size . copoint))
-- | The sum of the node count of the diff.
diffCostWithCachedDiffSizes :: Diff a Info -> Integer
diffCostWithCachedDiffSizes (Free (Annotated (Both (before, after)) _)) = size before + size after
diffCostWithCachedDiffSizes (Pure patch) = sum $ size . copoint <$> patch
-- | The absolute difference between the node counts of a diff.
diffCostWithAbsoluteDifferenceOfCachedDiffSizes :: Diff a Info -> Integer
diffCostWithAbsoluteDifferenceOfCachedDiffSizes (Free (Annotated (Both (before, after)) _)) = abs $ size before - size after
diffCostWithAbsoluteDifferenceOfCachedDiffSizes (Pure patch) = sum $ size . copoint <$> patch