perf: avoid negative environment lookup (#5429)

Avoids some `Environment.find?` lookup misses that become especially
expensive on the async branch
This commit is contained in:
Sebastian Ullrich 2024-11-08 16:37:39 +01:00 committed by GitHub
parent cb40ddad69
commit dac73c15c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)