Skip to content

Commit

Permalink
perf: optimize unfolding constant lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
Kha committed Nov 7, 2024
1 parent c779f3a commit 489c87a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Lean/Meta/WHNF.lean
Original file line number Diff line number Diff line change
Expand Up @@ -831,10 +831,12 @@ mutual
else
unfoldDefault ()
| .const declName lvls => do
let some cinfo ← getUnfoldableConstNoEx? declName | pure none
-- check smart unfolding only after `getUnfoldableConstNoEx?` because smart unfoldings have a
-- significant chance of not existing and `Environment.contains` misses are more costly
if smartUnfolding.get (← getOptions) && (← getEnv).contains (mkSmartUnfoldingNameFor declName) then
return none
else
let some cinfo ← getUnfoldableConstNoEx? declName | pure none
unless cinfo.hasValue do return none
deltaDefinition cinfo lvls
(fun _ => pure none)
Expand Down

0 comments on commit 489c87a

Please sign in to comment.