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-constraint.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-constraint.cpp')
| -rw-r--r-- | source/slang/slang-check-constraint.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/source/slang/slang-check-constraint.cpp b/source/slang/slang-check-constraint.cpp index a03043f31..129d3ed0c 100644 --- a/source/slang/slang-check-constraint.cpp +++ b/source/slang/slang-check-constraint.cpp @@ -391,11 +391,8 @@ namespace Slang // search for a conformance `Robin : ISidekick`, which involved // apply the substitutions we already know... - GenericSubstitution* solvedSubst = m_astBuilder->create<GenericSubstitution>(); - solvedSubst->genericDecl = genericDeclRef.getDecl(); - solvedSubst->outer = genericDeclRef.substitutions.substitutions; - solvedSubst->args = args; - resultSubst.substitutions = solvedSubst; + GenericSubstitution* solvedSubst = m_astBuilder->getOrCreateGenericSubstitution( + genericDeclRef.getDecl(), args, genericDeclRef.substitutions.substitutions); for( auto constraintDecl : genericDeclRef.getDecl()->getMembersOfType<GenericTypeConstraintDecl>() ) { @@ -412,7 +409,7 @@ namespace Slang if(subTypeWitness) { // We found a witness, so it will become an (implicit) argument. - solvedSubst->args.add(subTypeWitness); + args.add(subTypeWitness); } else { @@ -437,6 +434,8 @@ namespace Slang } } + resultSubst = m_astBuilder->getOrCreateGenericSubstitution( + genericDeclRef.getDecl(), args, genericDeclRef.substitutions.substitutions); return resultSubst; } @@ -546,12 +545,12 @@ namespace Slang return false; // Their arguments must unify - SLANG_RELEASE_ASSERT(fstGen->args.getCount() == sndGen->args.getCount()); - Index argCount = fstGen->args.getCount(); + SLANG_RELEASE_ASSERT(fstGen->getArgs().getCount() == sndGen->getArgs().getCount()); + Index argCount = fstGen->getArgs().getCount(); bool okay = true; for (Index aa = 0; aa < argCount; ++aa) { - if (!TryUnifyVals(constraints, fstGen->args[aa], sndGen->args[aa])) + if (!TryUnifyVals(constraints, fstGen->getArgs()[aa], sndGen->getArgs()[aa])) { okay = false; } |
