Skip to content

Commit abf41e7

Browse files
committed
[Constraint system] Look for parent/depth info in base constraint system.
Look first in the base constraint system for this information, so it only gets built once in the normal case.
1 parent 24b47b5 commit abf41e7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,12 @@ static void extendDepthMap(
528528

529529
Optional<std::pair<unsigned, Expr *>> ConstraintSystem::getExprDepthAndParent(
530530
Expr *expr) {
531+
// Check whether the parent has this information.
532+
if (baseCS && baseCS != this) {
533+
if (auto known = baseCS->getExprDepthAndParent(expr))
534+
return *known;
535+
}
536+
531537
// Bring the set of expression weights up to date.
532538
while (NumInputExprsInWeights < InputExprs.size()) {
533539
extendDepthMap(InputExprs[NumInputExprsInWeights], ExprWeights);
@@ -538,9 +544,6 @@ Optional<std::pair<unsigned, Expr *>> ConstraintSystem::getExprDepthAndParent(
538544
if (e != ExprWeights.end())
539545
return e->second;
540546

541-
if (baseCS && baseCS != this)
542-
return baseCS->getExprDepthAndParent(expr);
543-
544547
return None;
545548
}
546549

0 commit comments

Comments
 (0)