perf: fast paths for forEachWhere Expr.isFVar (#11973)
Add a fast path for the pattern `forEachWhere Expr.isFVar` to avoid setting up the expression traversal etc. Pattern initially noticed by @Rob23oba
This commit is contained in:
parent
d7cbdebf0b
commit
c91a2c63c2
2 changed files with 4 additions and 2 deletions
|
|
@ -156,7 +156,8 @@ mutual
|
|||
|
||||
/-- Collect dependencies of the given expression. -/
|
||||
partial def collectType (type : Expr) : ClosureM Unit := do
|
||||
type.forEachWhere Expr.isFVar fun e => collectFVar e.fvarId!
|
||||
if type.hasFVar then
|
||||
type.forEachWhere Expr.isFVar fun e => collectFVar e.fvarId!
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -99,7 +99,8 @@ def _root_.Lean.MVarId.getNondepPropHyps (mvarId : MVarId) : MetaM (Array FVarId
|
|||
let removeDeps (e : Expr) (candidates : FVarIdHashSet) : MetaM FVarIdHashSet := do
|
||||
let e ← instantiateMVars e
|
||||
let visit : StateRefT FVarIdHashSet MetaM FVarIdHashSet := do
|
||||
e.forEachWhere Expr.isFVar fun e => modify fun s => s.erase e.fvarId!
|
||||
if e.hasFVar then
|
||||
e.forEachWhere Expr.isFVar fun e => modify fun s => s.erase e.fvarId!
|
||||
get
|
||||
visit |>.run' candidates
|
||||
mvarId.withContext do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue