Skip to content

Fix a couple of performance regressions #37374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5936,17 +5936,33 @@ llvm::TinyPtrVector<CustomAttr *> VarDecl::getAttachedPropertyWrappers() const {

/// Whether this property has any attached property wrappers.
bool VarDecl::hasAttachedPropertyWrapper() const {
return !getAttachedPropertyWrappers().empty() || hasImplicitPropertyWrapper();
if (getAttrs().hasAttribute<CustomAttr>()) {
if (!getAttachedPropertyWrappers().empty())
return true;
}

if (hasImplicitPropertyWrapper())
return true;

return false;
}

bool VarDecl::hasImplicitPropertyWrapper() const {
if (!getAttachedPropertyWrappers().empty())
if (getAttrs().hasAttribute<CustomAttr>()) {
if (!getAttachedPropertyWrappers().empty())
return false;
}

if (isImplicit())
return false;

auto *dc = getDeclContext();
bool isClosureParam = isa<ParamDecl>(this) &&
dc->getContextKind() == DeclContextKind::AbstractClosureExpr;
return !isImplicit() && getName().hasDollarPrefix() && isClosureParam;
if (!isa<ParamDecl>(this))
return false;

if (!isa<AbstractClosureExpr>(getDeclContext()))
return false;

return getName().hasDollarPrefix();
}

bool VarDecl::hasExternalPropertyWrapper() const {
Expand Down
21 changes: 16 additions & 5 deletions lib/AST/DeclContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1038,11 +1038,22 @@ IterableDeclContext::castDeclToIterableDeclContext(const Decl *D) {
}

Optional<Fingerprint> IterableDeclContext::getBodyFingerprint() const {
auto mutableThis = const_cast<IterableDeclContext *>(this);
return evaluateOrDefault(getASTContext().evaluator,
ParseMembersRequest{mutableThis},
FingerprintAndMembers())
.fingerprint;
auto fileUnit = dyn_cast<FileUnit>(getAsGenericContext()->getModuleScopeContext());
if (!fileUnit)
return None;

if (isa<SourceFile>(fileUnit)) {
auto mutableThis = const_cast<IterableDeclContext *>(this);
return evaluateOrDefault(getASTContext().evaluator,
ParseMembersRequest{mutableThis},
FingerprintAndMembers())
.fingerprint;
}

if (getDecl()->isImplicit())
return None;

return fileUnit->loadFingerprint(this);
}

/// Return the DeclContext to compare when checking private access in
Expand Down