1
1
mirror of https://github.com/github/semantic.git synced 2024-12-11 08:45:48 +03:00

🔥 exactMatch.

This commit is contained in:
Rob Rix 2019-10-16 17:35:17 -04:00
parent d9505164fb
commit 70414495f5
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -103,15 +103,14 @@ dedupe = let tuples = sortOn fst . Map.elems . snd . foldl' go (0, Map.empty) in
go :: (Int, Map.Map DedupeKey (Int, (Entry, Declaration)))
-> (Entry, Declaration)
-> (Int, Map.Map DedupeKey (Int, (Entry, Declaration)))
go (index, m) x | Just (_, similar@(_, similarDecl)) <- Map.lookup (dedupeKey (snd x)) m
= if exactMatch similar x
go (index, m) x | Just (_, (_, similarDecl)) <- Map.lookup (dedupeKey (snd x)) m
= if similarDecl == snd x
then (succ index, m)
else
(succ index, Map.insert (dedupeKey similarDecl) (index, (Replaced, similarDecl)) m)
| otherwise = (succ index, Map.insert (dedupeKey (snd x)) (index, x) m)
dedupeKey decl = DedupeKey (toCategoryName decl, T.toLower (declarationIdentifier decl))
exactMatch = (==) `on` snd
-- | Construct a description of an 'Entry'.
entryChange :: Entry -> Text