perf(library/elaborator): avoid exception

Lean was spending 17% on the runtime "throwing exceptions" in the test tests/lean/implicit7.lean

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2013-12-10 16:31:33 -08:00
parent 1fb526a3d4
commit 5ae71e75bd

View file

@ -224,6 +224,11 @@ class elaborator::imp {
/** \brief Return true iff \c a is a proposition */ /** \brief Return true iff \c a is a proposition */
bool is_proposition(expr const & a, context const & ctx) { bool is_proposition(expr const & a, context const & ctx) {
if (is_metavar(a)) {
// Avoid exception at m_type_inferer.
// Throw is expensive in C++.
return false;
}
try { try {
return m_type_inferer.is_proposition(a, ctx); return m_type_inferer.is_proposition(a, ctx);
} catch (...) { } catch (...) {