Skip to content

Commit 7fa7c46

Browse files
committed
perf: optimize unfolding constant lookup
1 parent e551a36 commit 7fa7c46

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Lean/Meta/WHNF.lean

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,10 +798,12 @@ mutual
798798
else
799799
unfoldDefault ()
800800
| .const declName lvls => do
801+
let some cinfo ← getUnfoldableConstNoEx? declName | pure none
802+
-- check smart unfolding only after `getUnfoldableConstNoEx?` because smart unfoldings have a
803+
-- significant chance of not existing and `Environment.contains` misses are more costly
801804
if smartUnfolding.get (← getOptions) && (← getEnv).contains (mkSmartUnfoldingNameFor declName) then
802805
return none
803806
else
804-
let some cinfo ← getUnfoldableConstNoEx? declName | pure none
805807
unless cinfo.hasValue do return none
806808
deltaDefinition cinfo lvls
807809
(fun _ => pure none)

0 commit comments

Comments
 (0)