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
. fuzzyFinds (Name.toString . fst) query
. Map.toList
$ R.toMultimap (R.mapRan Left $ terms names)
<> R.toMultimap (R.mapRan Right $ types names)
-- `mapMonotonic` is safe here and saves a log n factor
$ (Set.mapMonotonic Left <$> R.toMultimap (terms names))
<> (Set.mapMonotonic Right <$> R.toMultimap (types names))
where
flatten (a, (b, c)) = (a, b, c)
fuzzyFinds :: (a -> String) -> [String] -> [a] -> [(FZF.Alignment, a)]