[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.
This commit is contained in:
Doug Gregor
2019-11-14 20:35:07 -08:00
parent 24b47b5673
commit abf41e73a8

View File

@@ -528,6 +528,12 @@ static void extendDepthMap(
Optional<std::pair<unsigned, Expr *>> ConstraintSystem::getExprDepthAndParent(
Expr *expr) {
// Check whether the parent has this information.
if (baseCS && baseCS != this) {
if (auto known = baseCS->getExprDepthAndParent(expr))
return *known;
}
// Bring the set of expression weights up to date.
while (NumInputExprsInWeights < InputExprs.size()) {
extendDepthMap(InputExprs[NumInputExprsInWeights], ExprWeights);
@@ -538,9 +544,6 @@ Optional<std::pair<unsigned, Expr *>> ConstraintSystem::getExprDepthAndParent(
if (e != ExprWeights.end())
return e->second;
if (baseCS && baseCS != this)
return baseCS->getExprDepthAndParent(expr);
return None;
}