Skip to content

Commit d245dac

Browse files
authored
Merge pull request #79086 from xedin/small-solver-perf-optimizations
[CSOptimizer] A few small performance optimizations
2 parents 96862b4 + 72340f3 commit d245dac

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/Sema/CSOptimizer.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ static bool isSupportedDisjunction(Constraint *disjunction) {
125125
// Non-operator disjunctions are supported only if they don't
126126
// have any generic choices.
127127
return llvm::all_of(choices, [&](Constraint *choice) {
128+
if (choice->isDisabled())
129+
return true;
130+
128131
if (choice->getKind() != ConstraintKind::BindOverload)
129132
return false;
130133

@@ -314,7 +317,13 @@ static void determineBestChoicesInContext(
314317
if (applicableFn.isNull()) {
315318
auto *locator = disjunction->getLocator();
316319
if (auto expr = getAsExpr(locator->getAnchor())) {
317-
if (auto *parentExpr = cs.getParentExpr(expr)) {
320+
auto *parentExpr = cs.getParentExpr(expr);
321+
// Look through optional evaluation, so
322+
// we can cover expressions like `a?.b + 2`.
323+
if (isExpr<OptionalEvaluationExpr>(parentExpr))
324+
parentExpr = cs.getParentExpr(parentExpr);
325+
326+
if (parentExpr) {
318327
// If this is a chained member reference or a direct operator
319328
// argument it could be prioritized since it helps to establish
320329
// context for other calls i.e. `(a.)b + 2` if `a` and/or `b`

validation-test/Sema/type_checker_perf/fast/swift_package_index_1.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -typecheck %s -solver-scope-threshold=1000
1+
// RUN: %target-swift-frontend -typecheck %s -solver-scope-threshold=500
22
// REQUIRES: tools-release,no_asan
33

44
public class Cookie {

0 commit comments

Comments
 (0)