Skip to content

Commit 6bca2da

Browse files
committed
Get rid of FixedSymUniques
1 parent fea46e0 commit 6bca2da

File tree

2 files changed

+11
-34
lines changed

2 files changed

+11
-34
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,13 +614,9 @@ object Contexts {
614614
/** A table for hash consing unique named types */
615615
private[core] val uniqueNamedTypes = new NamedTypeUniques
616616

617-
/** A table for hash consing unique symbolic named types */
618-
private[core] val uniqueWithFixedSyms = new WithFixedSymUniques
619-
620617
private def uniqueSets = Map(
621618
"uniques" -> uniques,
622619
"uniqueAppliedTypes" -> uniqueAppliedTypes,
623-
"uniqueWithFixedSyms" -> uniqueWithFixedSyms,
624620
"uniqueNamedTypes" -> uniqueNamedTypes)
625621

626622
/** A map that associates label and size of all uniques sets */

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

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,20 @@ object Uniques {
5252
e
5353
}
5454

55-
def enterIfNew(prefix: Type, designator: Designator)(implicit ctx: Context): NamedType = {
55+
def enterIfNew(prefix: Type, designator: Designator, isTerm: Boolean)(implicit ctx: Context): NamedType = {
5656
val h = doHash(designator, prefix)
5757
if (monitored) recordCaching(h, classOf[NamedType])
5858
def newType = {
59-
if (designator.isType) new CachedTypeRef(prefix, designator.asType, h)
60-
else new CachedTermRef(prefix, designator.asTerm, h)
59+
if (isTerm)
60+
designator match {
61+
case designator: TermSymbol => new TermRefWithFixedSym(prefix, designator, h)
62+
case _ => new CachedTermRef(prefix, designator.asTerm, h)
63+
}
64+
else
65+
designator match {
66+
case designator: TypeSymbol => new TypeRefWithFixedSym(prefix, designator, h)
67+
case _ => new CachedTypeRef(prefix, designator.asType, h)
68+
}
6169
}.init()
6270
if (h == NotCached) newType
6371
else {
@@ -67,33 +75,6 @@ object Uniques {
6775
}
6876
}
6977

70-
final class WithFixedSymUniques extends HashSet[WithFixedSym](Config.initialUniquesCapacity) with Hashable {
71-
override def hash(x: WithFixedSym): Int = x.hash
72-
73-
private def findPrevious(h: Int, prefix: Type, sym: Symbol): NamedType = {
74-
var e = findEntryByHash(h)
75-
while (e != null) {
76-
if ((e.prefix eq prefix) && (e.fixedSym eq sym)) return e
77-
e = nextEntryByHash(h)
78-
}
79-
e
80-
}
81-
82-
def enterIfNew(prefix: Type, name: Name, sym: Symbol)(implicit ctx: Context): NamedType = {
83-
val h = doHash(sym, prefix)
84-
if (monitored) recordCaching(h, classOf[WithFixedSym])
85-
def newType = {
86-
if (name.isTypeName) new TypeRefWithFixedSym(prefix, sym.asInstanceOf[TypeSymbol], h)
87-
else new TermRefWithFixedSym(prefix, sym.asInstanceOf[TermSymbol], h)
88-
}.init()
89-
if (h == NotCached) newType
90-
else {
91-
val r = findPrevious(h, prefix, sym)
92-
if (r ne null) r else addEntryAfterScan(newType)
93-
}
94-
}
95-
}
96-
9778
final class AppliedUniques extends HashSet[AppliedType](Config.initialUniquesCapacity) with Hashable {
9879
override def hash(x: AppliedType): Int = x.hash
9980

0 commit comments

Comments
 (0)