Skip to content

Commit

Permalink
perf: avoid negative environment lookup (#5429)
Browse files Browse the repository at this point in the history
Avoids some `Environment.find?` lookup misses that become especially
expensive on the async branch
  • Loading branch information
Kha authored Nov 8, 2024
1 parent cb40dda commit dac73c1
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 dac73c1

Please sign in to comment.