Skip to content

Commit bc8df3e

Browse files
committed
Optimize period equality tests
1 parent c920896 commit bc8df3e

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ object Periods {
2020
/** Are all base types in the current period guaranteed to be the same as in period `p`? */
2121
def currentHasSameBaseTypesAs(p: Period)(using Context): Boolean =
2222
val period = ctx.period
23-
period == p ||
23+
period.code == p.code ||
2424
period.runId == p.runId &&
2525
unfusedPhases(period.phaseId).sameBaseTypesStartId ==
2626
unfusedPhases(p.phaseId).sameBaseTypesStartId

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2867,7 +2867,7 @@ object SymDenotations {
28672867
}
28682868

28692869
def isValidAt(phase: Phase)(using Context) =
2870-
checkedPeriod == ctx.period ||
2870+
checkedPeriod.code == ctx.period.code ||
28712871
createdAt.runId == ctx.runId &&
28722872
createdAt.phaseId < unfusedPhases.length &&
28732873
sameGroup(unfusedPhases(createdAt.phaseId), phase) &&

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ object Symbols {
103103
/** The current denotation of this symbol */
104104
final def denot(using Context): SymDenotation = {
105105
util.Stats.record("Symbol.denot")
106-
if (checkedPeriod == ctx.period) lastDenot
106+
if checkedPeriod.code == ctx.period.code then lastDenot
107107
else computeDenot(lastDenot)
108108
}
109109

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2266,7 +2266,7 @@ object Types {
22662266
final def symbol(using Context): Symbol =
22672267
// We can rely on checkedPeriod (unlike in the definition of `denot` below)
22682268
// because SymDenotation#installAfter never changes the symbol
2269-
if (checkedPeriod == ctx.period) lastSymbol.asInstanceOf[Symbol]
2269+
if (checkedPeriod.code == ctx.period.code) lastSymbol.asInstanceOf[Symbol]
22702270
else computeSymbol
22712271

22722272
private def computeSymbol(using Context): Symbol =

0 commit comments

Comments
 (0)