@@ -377,12 +377,13 @@ We should also investigate the impact on memory consumption.
377377abbrev DefEqCache := PersistentHashMap DefEqCacheKey Bool
378378
379379/--
380- A `DefEqTransCache` is a `DefEqCache` that is only valid in the original `MetavarContext`.
381- It stores of the `numAssignments` from that original `MetavarContext`.
380+ A `DefEqTransCache` is a `DefEqCache` that is only valid in the `MetavarContext` in which it was declared .
381+ To keep track of whether this cache is still valid, it stores the `numAssignments` from the original `MetavarContext`.
382382If the `numAssignments` in the `MetavarContext` has increased, we invalidate this cache.
383- And when we revert the metavariable context in `checkpointDefEq`, if the `numAssignments`
384- in the original `MetavarContext` is smaller than in the cache, we revert the cache to its original.
385- -/
383+ And when reverting the metavariable context in `checkpointDefEq`, if the `numAssignments`
384+ in the original `MetavarContext` is smaller than in this cache, we also invalidate this cache,
385+ and revert to the original cache.
386+ -/
386387structure DefEqTransCache where
387388 cache : DefEqCache := {}
388389 numAssignments : Nat := 0
@@ -656,6 +657,7 @@ def resetCache : MetaM Unit :=
656657@[inline] def modifyInferTypeCache (f : InferTypeCache → InferTypeCache) : MetaM Unit :=
657658 modifyCache fun ⟨ic, c1, c2, c3, c4, c5⟩ => ⟨f ic, c1, c2, c3, c4, c5⟩
658659
660+ /-- Modify the defEq transient cache. If it is not valid anymore, reset it before modifying it. -/
659661@[inline] def modifyDefEqTransientCache (numAssignments : Nat) (f : DefEqCache → DefEqCache) : MetaM Unit :=
660662 modifyCache fun c =>
661663 let ⟨transCache, numAssignmentsOld⟩ := c.defEqTrans
0 commit comments