Skip to content

Commit c74c66d

Browse files
authored
Merge pull request #37374 from slavapestov/fix-perf-regressions
Fix a couple of performance regressions
2 parents eeeea25 + 161c837 commit c74c66d

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

lib/AST/Decl.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5936,17 +5936,33 @@ llvm::TinyPtrVector<CustomAttr *> VarDecl::getAttachedPropertyWrappers() const {
59365936

59375937
/// Whether this property has any attached property wrappers.
59385938
bool VarDecl::hasAttachedPropertyWrapper() const {
5939-
return !getAttachedPropertyWrappers().empty() || hasImplicitPropertyWrapper();
5939+
if (getAttrs().hasAttribute<CustomAttr>()) {
5940+
if (!getAttachedPropertyWrappers().empty())
5941+
return true;
5942+
}
5943+
5944+
if (hasImplicitPropertyWrapper())
5945+
return true;
5946+
5947+
return false;
59405948
}
59415949

59425950
bool VarDecl::hasImplicitPropertyWrapper() const {
5943-
if (!getAttachedPropertyWrappers().empty())
5951+
if (getAttrs().hasAttribute<CustomAttr>()) {
5952+
if (!getAttachedPropertyWrappers().empty())
5953+
return false;
5954+
}
5955+
5956+
if (isImplicit())
59445957
return false;
59455958

5946-
auto *dc = getDeclContext();
5947-
bool isClosureParam = isa<ParamDecl>(this) &&
5948-
dc->getContextKind() == DeclContextKind::AbstractClosureExpr;
5949-
return !isImplicit() && getName().hasDollarPrefix() && isClosureParam;
5959+
if (!isa<ParamDecl>(this))
5960+
return false;
5961+
5962+
if (!isa<AbstractClosureExpr>(getDeclContext()))
5963+
return false;
5964+
5965+
return getName().hasDollarPrefix();
59505966
}
59515967

59525968
bool VarDecl::hasExternalPropertyWrapper() const {

lib/AST/DeclContext.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,11 +1038,22 @@ IterableDeclContext::castDeclToIterableDeclContext(const Decl *D) {
10381038
}
10391039

10401040
Optional<Fingerprint> IterableDeclContext::getBodyFingerprint() const {
1041-
auto mutableThis = const_cast<IterableDeclContext *>(this);
1042-
return evaluateOrDefault(getASTContext().evaluator,
1043-
ParseMembersRequest{mutableThis},
1044-
FingerprintAndMembers())
1045-
.fingerprint;
1041+
auto fileUnit = dyn_cast<FileUnit>(getAsGenericContext()->getModuleScopeContext());
1042+
if (!fileUnit)
1043+
return None;
1044+
1045+
if (isa<SourceFile>(fileUnit)) {
1046+
auto mutableThis = const_cast<IterableDeclContext *>(this);
1047+
return evaluateOrDefault(getASTContext().evaluator,
1048+
ParseMembersRequest{mutableThis},
1049+
FingerprintAndMembers())
1050+
.fingerprint;
1051+
}
1052+
1053+
if (getDecl()->isImplicit())
1054+
return None;
1055+
1056+
return fileUnit->loadFingerprint(this);
10461057
}
10471058

10481059
/// Return the DeclContext to compare when checking private access in

0 commit comments

Comments
 (0)