perf: (try to) fix regression introduced by #3139

This commit is contained in:
Leonardo de Moura 2024-01-07 10:05:35 -08:00 committed by Sebastian Ullrich
parent b8b49c50b9
commit 29c245ceba

View file

@ -827,12 +827,17 @@ def reduceNative? (e : Expr) : MetaM (Option Expr) :=
| _ =>
return none
@[inline] def withNatValue {α} (a : Expr) (k : Nat → MetaM (Option α)) : MetaM (Option α) := do
@[inline] def withNatValue (a : Expr) (k : Nat → MetaM (Option α)) : MetaM (Option α) := do
if !a.hasExprMVar && a.hasFVar then
return none
let a ← instantiateMVars a
if a.hasExprMVar || a.hasFVar then
return none
let a ← whnf a
match a with
| Expr.const `Nat.zero _ => k 0
| Expr.lit (Literal.natVal v) => k v
| _ => return none
| .const ``Nat.zero _ => k 0
| .lit (.natVal v) => k v
| _ => return none
def reduceUnaryNatOp (f : Nat → Nat) (a : Expr) : MetaM (Option Expr) :=
withNatValue a fun a =>