Cleanup eq_functor

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2013-07-23 09:12:15 -07:00
parent 79d00f4d78
commit dd74284fdc

View file

@ -116,8 +116,10 @@ void expr_cell::dealloc() {
}
}
namespace expr_eq_ns {
static thread_local expr_cell_pair_set g_eq_visited;
class eq_functor {
expr_cell_pair_set m_eq_visited;
public:
bool apply(expr const & a, expr const & b) {
if (eqp(a, b)) return true;
if (a.hash() != b.hash()) return false;
@ -126,9 +128,9 @@ bool apply(expr const & a, expr const & b) {
if (is_prop(a)) return true;
if (is_shared(a) && is_shared(b)) {
auto p = std::make_pair(a.raw(), b.raw());
if (g_eq_visited.find(p) != g_eq_visited.end())
if (m_eq_visited.find(p) != m_eq_visited.end())
return true;
g_eq_visited.insert(p);
m_eq_visited.insert(p);
}
switch (a.kind()) {
case expr_kind::Var: lean_unreachable(); return true;
@ -161,10 +163,11 @@ bool apply(expr const & a, expr const & b) {
lean_unreachable();
return false;
}
} // namespace expr_eq
};
bool operator==(expr const & a, expr const & b) {
expr_eq_ns::g_eq_visited.clear();
return expr_eq_ns::apply(a, b);
eq_functor f;
return f.apply(a, b);
}
// Low-level pretty printer