Skip to content

Commit 0b1b4b2

Browse files
committed
Micro-optimization: InheritedCache#isValidAt
1 parent 5ab7c6c commit 0b1b4b2

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,13 +1241,13 @@ object SymDenotations {
12411241
*/
12421242
class ClassDenotation private[SymDenotations] (
12431243
symbol: Symbol,
1244-
ownerIfExists: Symbol,
1244+
maybeOwner: Symbol,
12451245
name: Name,
12461246
initFlags: FlagSet,
12471247
initInfo: Type,
12481248
initPrivateWithin: Symbol,
12491249
initRunId: RunId)
1250-
extends SymDenotation(symbol, ownerIfExists, name, initFlags, initInfo, initPrivateWithin) {
1250+
extends SymDenotation(symbol, maybeOwner, name, initFlags, initInfo, initPrivateWithin) {
12511251

12521252
import util.LRUCache
12531253

@@ -2011,6 +2011,7 @@ object SymDenotations {
20112011
protected def sameGroup(p1: Phase, p2: Phase): Boolean
20122012

20132013
private[this] var dependent: WeakHashMap[InheritedCache, Unit] = null
2014+
private[this] var checkedPeriod: Period = Nowhere
20142015

20152016
protected def invalidateDependents() = {
20162017
if (dependent != null) {
@@ -2026,9 +2027,11 @@ object SymDenotations {
20262027
}
20272028

20282029
def isValidAt(phase: Phase)(implicit ctx: Context) =
2029-
createdAt.runId == ctx.runId &&
2030-
createdAt.phaseId < ctx.phases.length &&
2031-
sameGroup(ctx.phases(createdAt.phaseId), phase)
2030+
checkedPeriod == ctx.period ||
2031+
createdAt.runId == ctx.runId &&
2032+
createdAt.phaseId < ctx.phases.length &&
2033+
sameGroup(ctx.phases(createdAt.phaseId), phase) &&
2034+
{ checkedPeriod = ctx.period; true }
20322035
}
20332036

20342037
private class InvalidCache extends InheritedCache {

0 commit comments

Comments
 (0)