Merge pull request #2179 from unisonweb/fix/faster-fzf

Avoid rebuilding term and type relations on each call to fuzzy find
This commit is contained in:
Rúnar 2021-07-08 09:54:12 -04:00 committed by GitHub
commit f1e5a630a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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)]