perf: macro_inline ctorIdx for single constructor inductives (#11379)

This PR sets `@[macro_inline]` on the (trivial) `.ctorIdx` for inductive
types with one constructor, to reduce the number of symbols generated by
the compiler.
This commit is contained in:
Joachim Breitner 2025-11-26 12:23:00 +01:00 committed by GitHub
parent 3772bb8685
commit 9ce8a062ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -71,16 +71,20 @@ public def mkCtorIdx (indName : Name) : MetaM Unit :=
value := mkApp value alt
pure value
mkLambdaFVars (xs.push x) value
addAndCompile (.defnDecl (← mkDefinitionValInferringUnsafe
let decl := .defnDecl (← mkDefinitionValInferringUnsafe
(name := declName)
(levelParams := info.levelParams)
(type := declType)
(value := declValue)
(hints := ReducibilityHints.abbrev)
))
)
addDecl decl
modifyEnv fun env => addToCompletionBlackList env declName
modifyEnv fun env => addProtected env declName
setReducibleAttribute declName
if info.numCtors = 1 then
setInlineAttribute declName .macroInline
compileDecl decl
-- Deprecated alias for enumeration types (which used to have `toCtorIdx`)
if (← isEnumType indName) then