From 0010b6b585ad4bedd02e8fe382db2ee090e51060 Mon Sep 17 00:00:00 2001 From: Paul Chiusano Date: Tue, 6 Jul 2021 18:18:27 -0400 Subject: [PATCH] Avoid calling `mapRan` and doing relation building on each call to fuzzy find --- unison-core/src/Unison/Names2.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/unison-core/src/Unison/Names2.hs b/unison-core/src/Unison/Names2.hs index c3356a493..cedb55c69 100644 --- a/unison-core/src/Unison/Names2.hs +++ b/unison-core/src/Unison/Names2.hs @@ -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)]