AST: Remove some unnecessary SubstitutionList copies

ASTContext::getSpecializedConformance() already copies the
substitutions, so remove some AllocateCopy() calls.

Also, add a new overload taking a SubstitutionMap instead.
This allows removing some gatherAllSubstitutions() calls,
which have an allocation inside them.

Finally, remove the now-unused ModuleDecl parameter from
ProtocolConformance::subst() and make it public.
This commit is contained in:
Slava Pestov
2017-03-06 17:38:14 -08:00
parent 69ae6cd588
commit c040c71ea9
14 changed files with 105 additions and 72 deletions

View File

@@ -802,12 +802,10 @@ ModuleDecl::lookupConformance(Type type, ProtocolDecl *protocol,
if (!explicitConformanceType->isEqual(type)) {
// Gather the substitutions we need to map the generic conformance to
// the specialized conformance.
auto substitutions = type->gatherAllSubstitutions(this, resolver,
explicitConformanceDC);
auto subMap = type->getContextSubstitutionMap(this, explicitConformanceDC);
// Create the specialized conformance entry.
auto result = ctx.getSpecializedConformance(type, conformance,
substitutions);
auto result = ctx.getSpecializedConformance(type, conformance, subMap);
return ProtocolConformanceRef(result);
}
}