Avoid calling mapRan and doing relation building on each call to fuzzy find

This commit is contained in:
Paul Chiusano 2021-07-06 18:18:27 -04:00
parent 3c8534d192
commit 0010b6b585

View File

@ -86,8 +86,9 @@ fuzzyFind query names =
fmap flatten fmap flatten
. fuzzyFinds (Name.toString . fst) query . fuzzyFinds (Name.toString . fst) query
. Map.toList . Map.toList
$ R.toMultimap (R.mapRan Left $ terms names) -- `mapMonotonic` is safe here and saves a log n factor
<> R.toMultimap (R.mapRan Right $ types names) $ (Set.mapMonotonic Left <$> R.toMultimap (terms names))
<> (Set.mapMonotonic Right <$> R.toMultimap (types names))
where where
flatten (a, (b, c)) = (a, b, c) flatten (a, (b, c)) = (a, b, c)
fuzzyFinds :: (a -> String) -> [String] -> [a] -> [(FZF.Alignment, a)] fuzzyFinds :: (a -> String) -> [String] -> [a] -> [(FZF.Alignment, a)]