Skip to content

Commit d0c377b

Browse files
committed
Further optimizations of denot
Make the overridden method less frequently called
1 parent f2cdce8 commit d0c377b

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -415,18 +415,19 @@ object Symbols {
415415
else computeDenot(lastd)
416416
}
417417

418-
protected def computeDenot(lastd: SymDenotation)(implicit ctx: Context): SymDenotation = {
418+
private def computeDenot(lastd: SymDenotation)(implicit ctx: Context): SymDenotation = {
419419
val now = ctx.period
420420
checkedPeriod = now
421-
if (lastd.validFor contains now) {
422-
lastd
423-
} else {
424-
val newd = lastd.current.asInstanceOf[SymDenotation]
425-
lastDenot = newd
426-
newd
427-
}
421+
if (lastd.validFor contains now) lastd else recomputeDenot(lastd)
422+
}
423+
424+
/** Overridden in NoSymbol */
425+
protected def recomputeDenot(lastd: SymDenotation)(implicit ctx: Context) = {
426+
val newd = lastd.current.asInstanceOf[SymDenotation]
427+
lastDenot = newd
428+
newd
428429
}
429-
430+
430431
/** The initial denotation of this symbol, without going through `current` */
431432
final def initialDenot(implicit ctx: Context): SymDenotation =
432433
lastDenot.initial
@@ -646,7 +647,7 @@ object Symbols {
646647
@sharable object NoSymbol extends Symbol(NoCoord, 0) {
647648
denot = NoDenotation
648649
override def associatedFile(implicit ctx: Context): AbstractFile = NoSource.file
649-
override def computeDenot(lastd: SymDenotation)(implicit ctx: Context): SymDenotation = NoDenotation
650+
override def recomputeDenot(lastd: SymDenotation)(implicit ctx: Context): SymDenotation = NoDenotation
650651
}
651652

652653
implicit class Copier[N <: Name](sym: Symbol { type ThisName = N })(implicit ctx: Context) {

0 commit comments

Comments
 (0)