summaryrefslogtreecommitdiff
path: root/source/slang/slang-lookup.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-07-16 23:43:06 -0700
committerGitHub <noreply@github.com>2025-07-17 06:43:06 +0000
commit020a16072923a66ae0985be618fd32310aa87242 (patch)
tree92eafa62d59c2fed44aa1afd47a14a31b88a22fe /source/slang/slang-lookup.cpp
parent5937e1e6bb3afcf84b01abadcf1eb527933449f3 (diff)
Improve lookup performance. (#7798)
* Improve lookup performance. * Cleanup. * Improve autocompletion latency.
Diffstat (limited to 'source/slang/slang-lookup.cpp')
-rw-r--r--source/slang/slang-lookup.cpp46
1 files changed, 27 insertions, 19 deletions
diff --git a/source/slang/slang-lookup.cpp b/source/slang/slang-lookup.cpp
index a9b472776..0fd66abc3 100644
--- a/source/slang/slang-lookup.cpp
+++ b/source/slang/slang-lookup.cpp
@@ -357,6 +357,32 @@ static Type* _maybeSpecializeSuperType(
return superType;
}
+void FacetImpl::init(ASTBuilder* astBuilder)
+{
+ if (directness != Facet::Directness::Self)
+ {
+ // Depending on the type of the facet, we may want to specialize the
+ // declRef that we are going to lookup in. If the facet represents
+ // an extension, we should just lookup in the extension decl.
+ //
+ // If the facet is an extension to an interface type, we should
+ // specialize the interface declRef to the concrete type that this
+ // extension applied to.
+ //
+ // If the facet represents an implementation of interface type,
+ // we should also specialize the interface declRef with the concrete
+ // type info.
+ //
+ declRefForMemberLookup =
+ _maybeSpecializeSuperTypeDeclRef(astBuilder, origin.declRef, getType(), subtypeWitness)
+ .as<ContainerDecl>();
+ }
+ else
+ {
+ declRefForMemberLookup = origin.declRef.as<ContainerDecl>();
+ }
+}
+
static void _lookUpMembersInType(
ASTBuilder* astBuilder,
Name* name,
@@ -490,27 +516,9 @@ static void _lookupMembersInSuperTypeFacets(
BreadcrumbInfo* newBreadcrumbs = inBreadcrumbs;
BreadcrumbInfo subtypeInfo;
- auto parentDeclRef = containerDeclRef;
+ auto parentDeclRef = facet->declRefForMemberLookup;
if (facet->directness != Facet::Directness::Self)
{
- // Depending on the type of the facet, we may want to specialize the
- // declRef that we are going to lookup in. If the facet represents
- // an extension, we should just lookup in the extension decl.
- //
- // If the facet is an extension to an interface type, we should
- // specialize the interface declRef to the concrete type that this
- // extension applied to.
- //
- // If the facet represents an implementation of interface type,
- // we should also specialize the interface declRef with the concrete
- // type info.
- //
- parentDeclRef = _maybeSpecializeSuperTypeDeclRef(
- astBuilder,
- containerDeclRef,
- facet->getType(),
- facet->subtypeWitness)
- .as<ContainerDecl>();
if (as<ThisTypeDecl>(parentDeclRef.getDecl()) && getText(name) == "This")
{
// If we are going looking for `This` in a `ThisType`, we just need to return the