diff options
| author | Yong He <yonghe@outlook.com> | 2022-09-13 13:11:48 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-13 13:11:48 -0700 |
| commit | f216b77752b9e4aea52882b2110ceb1cc64a2171 (patch) | |
| tree | fbb33485b7260bc0f89b406e1be6fb8196f94196 /source/slang/slang-check-conformance.cpp | |
| parent | 9f3e83cf0d664c87a618edf08d834829178030e6 (diff) | |
Deduplicate AST type nodes and cache lookup operations. (#2397)
* wip: dedup AST type nodes and cache lookup.
* Fix.
* Remove profiling.
* Fixes.
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-conformance.cpp')
| -rw-r--r-- | source/slang/slang-check-conformance.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/source/slang/slang-check-conformance.cpp b/source/slang/slang-check-conformance.cpp index 5889c6140..e0c1f3702 100644 --- a/source/slang/slang-check-conformance.cpp +++ b/source/slang/slang-check-conformance.cpp @@ -10,10 +10,11 @@ namespace Slang DeclaredSubtypeWitness* SemanticsVisitor::createSimpleSubtypeWitness( TypeWitnessBreadcrumb* breadcrumb) { - DeclaredSubtypeWitness* witness = m_astBuilder->create<DeclaredSubtypeWitness>(); - witness->sub = breadcrumb->sub; - witness->sup = breadcrumb->sup; - witness->declRef = breadcrumb->declRef; + DeclaredSubtypeWitness* witness = m_astBuilder->getOrCreate<DeclaredSubtypeWitness>( + breadcrumb->sub, + breadcrumb->sup, + breadcrumb->declRef.decl, + breadcrumb->declRef.substitutions.substitutions); return witness; } @@ -82,12 +83,11 @@ namespace Slang // where `[...]` represents the "hole" we leave // open to fill in next. // - DeclaredSubtypeWitness* declaredWitness = m_astBuilder->create<DeclaredSubtypeWitness>(); - declaredWitness->sub = bb->sub; - declaredWitness->sup = bb->sup; - declaredWitness->declRef = bb->declRef; + DeclaredSubtypeWitness* declaredWitness = + m_astBuilder->getOrCreate<DeclaredSubtypeWitness>( + bb->sub, bb->sup, bb->declRef.decl, bb->declRef.substitutions.substitutions); - TransitiveSubtypeWitness* transitiveWitness = m_astBuilder->create<TransitiveSubtypeWitness>(); + TransitiveSubtypeWitness* transitiveWitness = m_astBuilder->getOrCreateWithDefaultCtor<TransitiveSubtypeWitness>(subType, bb->sup, declaredWitness); transitiveWitness->sub = subType; transitiveWitness->sup = bb->sup; transitiveWitness->midToSup = declaredWitness; |
