Merge pull request #2170 from unisonweb/fix/fast-fqn

Avoid building the complete FQN mapping when only a few keys are needed
This commit is contained in:
mergify[bot] 2021-07-02 15:37:24 +00:00 committed by GitHub
commit 3c8534d192
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -554,22 +554,19 @@ prettyDefinitionsBySuffixes relativeTo root renderWidth suffixifyBindings codeba
getCurrentParseNames (fromMaybe Path.empty relativeTo) branch
ppe = PPE.fromNamesDecl hqLength printNames
width = mayDefault renderWidth
isAbsolute (Name.toText -> n) = "." `Text.isPrefixOf` n && n /= "."
termFqns :: Map Reference (Set Text)
termFqns = Map.mapWithKey f terms
where
rel = R.filterDom (\n -> "." `Text.isPrefixOf` n && n /= ".")
. R.mapDom Name.toText
. Names.terms
$ currentNames parseNames
f k _ = R.lookupRan (Referent.Ref' k) rel
rel = Names.terms $ currentNames parseNames
f k _ = Set.fromList . fmap Name.toText . filter isAbsolute . toList
$ R.lookupRan (Referent.Ref' k) rel
typeFqns :: Map Reference (Set Text)
typeFqns = Map.mapWithKey f types
where
rel = R.filterDom (\n -> "." `Text.isPrefixOf` n && n /= ".")
. R.mapDom Name.toText
. Names.types
$ currentNames parseNames
f k _ = R.lookupRan k rel
rel = Names.types $ currentNames parseNames
f k _ = Set.fromList . fmap Name.toText . filter isAbsolute . toList
$ R.lookupRan k rel
flatten = Set.toList . fromMaybe Set.empty
mkTermDefinition r tm = do
ts <- lift (Codebase.getTypeOfTerm codebase r)