1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 09:15:01 +03:00

Don’t change diff sizes; don’t traverse subtrees to compute cost in SES.

This commit is contained in:
Rob Rix 2016-06-03 15:09:10 -04:00
parent 58363fc4de
commit 0976c1e452

View File

@ -94,12 +94,7 @@ diffFiles parser renderer sourceBlobs = do
pure $! renderer textDiff sourceBlobs
where construct :: CofreeF (Syntax Text) (Both Info) (Diff Text Info) -> Diff Text Info
construct (info :< syntax) = free (Free ((setCost <$> info <*> sumCost syntax) :< syntax))
setCost info cost = info { cost = cost }
sumCost = fmap getSum . foldMap (fmap Sum . getCost)
getCost diff = case runFree diff of
Free (info :< _) -> cost <$> info
Pure patch -> uncurry both (fromThese 0 0 (unPatch (cost . extract <$> patch)))
construct = free . Free
-- | The sum of the node count of the diffs patches.
diffCostWithCachedTermSizes :: Diff a Info -> Integer