perf(kernel/metavar): improve occurs_expr method
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
0f44e3c9f4
commit
46005b4ffe
1 changed files with 11 additions and 7 deletions
|
@ -256,18 +256,22 @@ level substitution::instantiate_metavars_wo_jst(level const & l) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool substitution::occurs_expr(name const & m, expr const & e) const {
|
bool substitution::occurs_expr(name const & m, expr const & e) const {
|
||||||
if (!has_metavar(e))
|
if (!has_expr_metavar(e))
|
||||||
return false;
|
return false;
|
||||||
auto it = find(e, [&](expr const & e, unsigned) {
|
bool found = false;
|
||||||
|
for_each(e, [&](expr const & e, unsigned) {
|
||||||
|
if (found || !has_expr_metavar(e)) return false;
|
||||||
if (is_metavar(e)) {
|
if (is_metavar(e)) {
|
||||||
if (mlocal_name(e) == m)
|
if (mlocal_name(e) == m)
|
||||||
return true;
|
found = true;
|
||||||
auto s = get_expr(e);
|
auto s = get_expr(e);
|
||||||
return s && occurs_expr(m, *s);
|
if (s && occurs_expr(m, *s))
|
||||||
} else {
|
found = true;
|
||||||
return false;
|
return false; // do not visit type
|
||||||
}
|
}
|
||||||
|
if (is_local(e)) return false; // do not visit type
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
return static_cast<bool>(it);
|
return found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue