mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[AST] Lazily compute ProtocolDecl::getKnownProtocolKind()
Rather than eagerly doing a bunch of name lookups to establish the known protocol kind, lazily match the ProtocolDecl to the list of known protocols as-needed. This eliminates a bunch of up-front unqualified name lookups when spinning up a type checker.
This commit is contained in:
@@ -4384,6 +4384,24 @@ void ProtocolDecl::setRequirementSignature(ArrayRef<Requirement> requirements) {
|
||||
}
|
||||
}
|
||||
|
||||
void ProtocolDecl::computeKnownProtocolKind() const {
|
||||
auto module = getModuleContext();
|
||||
if (module != module->getASTContext().getStdlibModule() &&
|
||||
!module->getName().is("Foundation")) {
|
||||
const_cast<ProtocolDecl *>(this)->Bits.ProtocolDecl.KnownProtocol = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned value =
|
||||
llvm::StringSwitch<unsigned>(getBaseName().userFacingName())
|
||||
#define PROTOCOL_WITH_NAME(Id, Name) \
|
||||
.Case(Name, static_cast<unsigned>(KnownProtocolKind::Id) + 2)
|
||||
#include "swift/AST/KnownProtocols.def"
|
||||
.Default(1);
|
||||
|
||||
const_cast<ProtocolDecl *>(this)->Bits.ProtocolDecl.KnownProtocol = value;
|
||||
}
|
||||
|
||||
void AbstractStorageDecl::overwriteImplInfo(StorageImplInfo implInfo) {
|
||||
setFieldsFromImplInfo(implInfo);
|
||||
Accessors.getPointer()->overwriteImplInfo(implInfo);
|
||||
|
||||
Reference in New Issue
Block a user