perf: prevent unnecessary allocations of EST.Out.ok (#13163)

This commit is contained in:
Henrik Böving 2026-03-27 23:10:24 +01:00 committed by GitHub
parent ae19b3e248
commit 8c0bb68ee5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 0 deletions

View file

@ -717,20 +717,25 @@ def recordSynthPendingFailure (type : Expr) : MetaM Unit := do
modifyDiag fun { unfoldCounter, unfoldAxiomCounter, heuristicCounter, instanceCounter, synthPendingFailures } =>
{ unfoldCounter, unfoldAxiomCounter, heuristicCounter, instanceCounter, synthPendingFailures := synthPendingFailures.insert type msg }
@[inline]
def getLocalInstances : MetaM LocalInstances :=
return (← read).localInstances
@[inline]
def getConfig : MetaM Config :=
return (← read).config
@[inline]
def getConfigWithKey : MetaM ConfigWithKey :=
return (← getConfig).toConfigWithKey
/-- Return the array of postponed universe level constraints. -/
@[inline]
def getPostponed : MetaM (PersistentArray PostponedEntry) :=
return (← get).postponed
/-- Set the array of postponed universe level constraints. -/
@[inline]
def setPostponed (postponed : PersistentArray PostponedEntry) : MetaM Unit :=
modify fun s => { s with postponed := postponed }
@ -904,12 +909,15 @@ def mkConstWithFreshMVarLevels (declName : Name) : MetaM Expr := do
return mkConst declName (← mkFreshLevelMVarsFor info)
/-- Return current transparency setting/mode. -/
@[inline]
def getTransparency : MetaM TransparencyMode :=
return (← getConfig).transparency
@[inline]
def shouldReduceAll : MetaM Bool :=
return (← getTransparency) == TransparencyMode.all
@[inline]
def shouldReduceReducibleOnly : MetaM Bool :=
return (← getTransparency) == TransparencyMode.reducible

View file

@ -445,27 +445,33 @@ unsafe def MethodsRef.toMethodsImpl (m : MethodsRef) : Methods :=
@[implemented_by MethodsRef.toMethodsImpl]
opaque MethodsRef.toMethods (m : MethodsRef) : Methods
@[inline]
def getMethods : SimpM Methods :=
return MethodsRef.toMethods (← read)
@[inline]
def pre (e : Expr) : SimpM Step := do
(← getMethods).pre e
@[inline]
def post (e : Expr) : SimpM Step := do
(← getMethods).post e
@[inline] def getContext : SimpM Context :=
readThe Context
@[inline]
def getConfig : SimpM Config :=
return (← getContext).config
@[inline] def withParent (parent : Expr) (f : SimpM α) : SimpM α :=
withTheReader Context (fun ctx => { ctx with parent? := parent }) f
@[inline]
def getSimpTheorems : SimpM SimpTheoremsArray :=
return (← readThe Context).simpTheorems
@[inline]
def getSimpCongrTheorems : SimpM SimpCongrTheorems :=
return (← readThe Context).congrTheorems
@ -473,6 +479,7 @@ def getSimpCongrTheorems : SimpM SimpCongrTheorems :=
Returns `true` if `simp` is in `dsimp` mode.
That is, only transformations that preserve definitional equality should be applied.
-/
@[inline]
def inDSimp : SimpM Bool :=
return (← readThe Context).inDSimp

View file

@ -114,6 +114,7 @@ where
false
/-- Determine if tracing is available for a given class, checking ancestor classes if appropriate. -/
@[inline]
def isTracingEnabledFor (cls : Name) : m Bool := do
return checkTraceOption (← MonadTrace.getInheritedTraceOptions) (← getOptions) cls