perf: faster LCNF internalization (#12878)

This PR speeds up the LCNF internalization procedure.
This commit is contained in:
Henrik Böving 2026-03-11 09:15:05 +01:00 committed by GitHub
parent 7acf5710c4
commit 9fac847f5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -32,14 +32,10 @@ def InternalizeM.run' (x : InternalizeM pu α) (state : FVarSubst pu) (ctx : Con
private def refreshBinderName (binderName : Name) : InternalizeM pu Name := do
match binderName with
| .num p _ =>
let r := .num p (← getThe CompilerM.State).nextIdx
modifyThe CompilerM.State fun s => { s with nextIdx := s.nextIdx + 1 }
return r
return .num p (← modifyGetThe CompilerM.State fun s => (s.nextIdx, { s with nextIdx := s.nextIdx + 1 }))
| _ =>
if (← read).uniqueIdents then
let r := .num binderName (← getThe CompilerM.State).nextIdx
modifyThe CompilerM.State fun s => { s with nextIdx := s.nextIdx + 1 }
return r
return .num binderName (← modifyGetThe CompilerM.State fun s => (s.nextIdx, { s with nextIdx := s.nextIdx + 1 }))
else
return binderName
@ -59,7 +55,10 @@ private def mkNewFVarId (fvarId : FVarId) : InternalizeM pu FVarId := do
addFVarSubst fvarId fvarId'
return fvarId'
private partial def internalizeExpr (e : Expr) : InternalizeM pu Expr :=
private partial def internalizeExpr (e : Expr) : InternalizeM pu Expr := do
if pu == .impure then
-- impure types don't contain fvars
return e
go e
where
goApp (e : Expr) : InternalizeM pu Expr := do