perf(frontends/lean/elaborator): fix performance bottleneck

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2014-07-22 17:45:45 -07:00
parent 697bcf4b4f
commit 35e7302d8a
2 changed files with 5 additions and 4 deletions

View file

@ -307,9 +307,9 @@ class elaborator {
substitution subst = next->first.get_subst(); substitution subst = next->first.get_subst();
buffer<constraint> cs; buffer<constraint> cs;
expr const & mvar = get_app_fn(m_meta); expr const & mvar = get_app_fn(m_meta);
cs.push_back(mk_eq_cnstr(mvar, subst.instantiate(mvar), m_jst)); cs.push_back(mk_eq_cnstr(mvar, subst.d_instantiate(mvar), m_jst));
for (auto const & mvar : m_mvars_in_meta_type) for (auto const & mvar : m_mvars_in_meta_type)
cs.push_back(mk_eq_cnstr(mvar, subst.instantiate(mvar), m_jst)); cs.push_back(mk_eq_cnstr(mvar, subst.d_instantiate(mvar), m_jst));
return optional<constraints>(to_list(cs.begin(), cs.end())); return optional<constraints>(to_list(cs.begin(), cs.end()));
} }
return optional<constraints>(); return optional<constraints>();
@ -424,7 +424,7 @@ public:
\remark We update \c m_accumulated with any justifications used. \remark We update \c m_accumulated with any justifications used.
*/ */
expr instantiate_metavars(expr const & e) { expr instantiate_metavars(expr const & e) {
auto e_j = m_subst.instantiate_metavars(e); auto e_j = m_subst.d_instantiate_metavars(e);
m_accumulated = mk_composite1(m_accumulated, e_j.second); m_accumulated = mk_composite1(m_accumulated, e_j.second);
return e_j.first; return e_j.first;
} }
@ -1128,7 +1128,7 @@ public:
/** \brief Apply substitution and solve remaining metavariables using tactics. */ /** \brief Apply substitution and solve remaining metavariables using tactics. */
expr apply(substitution & s, expr const & e, name_set & univ_params, buffer<name> & new_params) { expr apply(substitution & s, expr const & e, name_set & univ_params, buffer<name> & new_params) {
expr r = s.instantiate(e); expr r = s.d_instantiate(e);
if (has_univ_metavar(r)) if (has_univ_metavar(r))
r = univ_metavars_to_params_fn(m_env, m_lls, s, univ_params, new_params)(r); r = univ_metavars_to_params_fn(m_env, m_lls, s, univ_params, new_params)(r);
r = solve_unassigned_mvars(s, r); r = solve_unassigned_mvars(s, r);

View file

@ -110,6 +110,7 @@ public:
*/ */
expr instantiate_metavars_wo_jst(expr const & e) const; expr instantiate_metavars_wo_jst(expr const & e) const;
expr instantiate(expr const & e) const { return instantiate_metavars_wo_jst(e); } expr instantiate(expr const & e) const { return instantiate_metavars_wo_jst(e); }
expr d_instantiate(expr const & e) { return d_instantiate_metavars_wo_jst(e); }
std::pair<expr, substitution> updt_instantiate_metavars_wo_jst(expr const & e) const; std::pair<expr, substitution> updt_instantiate_metavars_wo_jst(expr const & e) const;