Skip to content

Commit a5195f8

Browse files
Avoid recomputing isUpToDate
1 parent 4a4ad17 commit a5195f8

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5123,11 +5123,6 @@ object Types extends TypeUtils {
51235123
tp.underlying
51245124
}
51255125

5126-
def isUpToDate: Boolean =
5127-
(reductionContext ne null) &&
5128-
reductionContext.keysIterator.forall: tp =>
5129-
reductionContext(tp) `eq` contextInfo(tp)
5130-
51315126
def setReductionContext(): Unit =
51325127
new TypeTraverser:
51335128
var footprint: Set[Type] = Set()
@@ -5162,15 +5157,22 @@ object Types extends TypeUtils {
51625157
matchTypes.println(i"footprint for $thisMatchType $hashCode: ${footprint.toList.map(x => (x, contextInfo(x)))}%, %")
51635158
end setReductionContext
51645159

5160+
def changedReductionContext(): Boolean =
5161+
val isUpToDate =
5162+
(reductionContext ne null) &&
5163+
reductionContext.keysIterator.forall: tp =>
5164+
reductionContext(tp) `eq` contextInfo(tp)
5165+
if !isUpToDate then setReductionContext()
5166+
!isUpToDate
5167+
51655168
record("MatchType.reduce called")
51665169
if !Config.cacheMatchReduced
51675170
|| myReduced == null
5168-
|| !isUpToDate
5171+
|| changedReductionContext()
51695172
|| MatchTypeTrace.isRecording
51705173
then
51715174
record("MatchType.reduce computed")
51725175
if (myReduced != null) record("MatchType.reduce cache miss")
5173-
if !isUpToDate then setReductionContext()
51745176
val saved = ctx.typerState.snapshot()
51755177
try
51765178
myReduced = trace(i"reduce match type $this $hashCode", matchTypes, show = true):

0 commit comments

Comments
 (0)