Skip to content

Commit 3045669

Browse files
committed
Optimize period equality tests
1 parent 6ec7f72 commit 3045669

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
@@ -2863,7 +2863,7 @@ object SymDenotations {
28632863
}
28642864

28652865
def isValidAt(phase: Phase)(using Context) =
2866-
checkedPeriod == ctx.period ||
2866+
checkedPeriod.code == ctx.period.code ||
28672867
createdAt.runId == ctx.runId &&
28682868
createdAt.phaseId < unfusedPhases.length &&
28692869
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
@@ -2263,7 +2263,7 @@ object Types {
22632263
final def symbol(using Context): Symbol =
22642264
// We can rely on checkedPeriod (unlike in the definition of `denot` below)
22652265
// because SymDenotation#installAfter never changes the symbol
2266-
if (checkedPeriod == ctx.period) lastSymbol.asInstanceOf[Symbol]
2266+
if (checkedPeriod.code == ctx.period.code) lastSymbol.asInstanceOf[Symbol]
22672267
else computeSymbol
22682268

22692269
private def computeSymbol(using Context): Symbol =

0 commit comments

Comments
 (0)