mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[ConstraintSystem] Guard all the performance hacks with a flag
Package the flag into `performanceHacksEnabled()` method on `ConstraintSystem` and start using it to wrap all of the hacks in constraint generator and the solver.
This commit is contained in:
@@ -10191,13 +10191,15 @@ performMemberLookup(ConstraintKind constraintKind, DeclNameRef memberName,
|
||||
if (path.back().getKind() == ConstraintLocator::ConstructorMember)
|
||||
isImplicitInit = true;
|
||||
|
||||
if (auto *applyExpr = getAsExpr<ApplyExpr>(anchor)) {
|
||||
if (auto *argExpr = applyExpr->getArgs()->getUnlabeledUnaryExpr()) {
|
||||
favoredType = getFavoredType(argExpr);
|
||||
|
||||
if (!favoredType) {
|
||||
optimizeConstraints(argExpr);
|
||||
if (performanceHacksEnabled()) {
|
||||
if (auto *applyExpr = getAsExpr<ApplyExpr>(anchor)) {
|
||||
if (auto *argExpr = applyExpr->getArgs()->getUnlabeledUnaryExpr()) {
|
||||
favoredType = getFavoredType(argExpr);
|
||||
|
||||
if (!favoredType) {
|
||||
optimizeConstraints(argExpr);
|
||||
favoredType = getFavoredType(argExpr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10312,22 +10314,24 @@ performMemberLookup(ConstraintKind constraintKind, DeclNameRef memberName,
|
||||
// If the invocation's argument expression has a favored type,
|
||||
// use that information to determine whether a specific overload for
|
||||
// the candidate should be favored.
|
||||
if (isa<ConstructorDecl>(decl) && favoredType &&
|
||||
result.FavoredChoice == ~0U) {
|
||||
auto *ctor = cast<ConstructorDecl>(decl);
|
||||
if (performanceHacksEnabled()) {
|
||||
if (isa<ConstructorDecl>(decl) && favoredType &&
|
||||
result.FavoredChoice == ~0U) {
|
||||
auto *ctor = cast<ConstructorDecl>(decl);
|
||||
|
||||
// Only try and favor monomorphic unary initializers.
|
||||
if (!ctor->isGenericContext()) {
|
||||
if (!ctor->getMethodInterfaceType()->hasError()) {
|
||||
// The constructor might have an error type because we don't skip
|
||||
// invalid decls for code completion
|
||||
auto args = ctor->getMethodInterfaceType()
|
||||
->castTo<FunctionType>()
|
||||
->getParams();
|
||||
if (args.size() == 1 && !args[0].hasLabel() &&
|
||||
args[0].getPlainType()->isEqual(favoredType)) {
|
||||
if (!isDeclUnavailable(decl, memberLocator))
|
||||
result.FavoredChoice = result.ViableCandidates.size();
|
||||
// Only try and favor monomorphic unary initializers.
|
||||
if (!ctor->isGenericContext()) {
|
||||
if (!ctor->getMethodInterfaceType()->hasError()) {
|
||||
// The constructor might have an error type because we don't skip
|
||||
// invalid decls for code completion
|
||||
auto args = ctor->getMethodInterfaceType()
|
||||
->castTo<FunctionType>()
|
||||
->getParams();
|
||||
if (args.size() == 1 && !args[0].hasLabel() &&
|
||||
args[0].getPlainType()->isEqual(favoredType)) {
|
||||
if (!isDeclUnavailable(decl, memberLocator))
|
||||
result.FavoredChoice = result.ViableCandidates.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user