Skip to content

Commit 5232d5a

Browse files
committed
Use IdentityHashMaps in pickler
1 parent f9b2df5 commit 5232d5a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@ class TreePickler(pickler: TastyPickler) {
4444

4545
private val symRefs = Symbols.newMutableSymbolMap[Addr]
4646
private val forwardSymRefs = Symbols.newMutableSymbolMap[List[Addr]]
47-
private val pickledTypes = new java.util.IdentityHashMap[Type, Any] // Value type is really Addr, but that's not compatible with null
47+
private val pickledTypes = util.IdentityHashMap[Type, AnyRef]() // Value type is really Addr, but that's not compatible with null
4848

4949
/** A list of annotation trees for every member definition, so that later
5050
* parallel position pickling does not need to access and force symbols.
5151
*/
52-
private val annotTrees = util.HashTable[untpd.MemberDef, mutable.ListBuffer[Tree]]()
52+
private val annotTrees = util.IdentityHashMap[untpd.MemberDef, mutable.ListBuffer[Tree]]()
5353

5454
/** A map from member definitions to their doc comments, so that later
5555
* parallel comment pickling does not need to access symbols of trees (which
5656
* would involve accessing symbols of named types and possibly changing phases
5757
* in doing so).
5858
*/
59-
private val docStrings = util.HashTable[untpd.MemberDef, Comment]()
59+
private val docStrings = util.IdentityHashMap[untpd.MemberDef, Comment]()
6060

6161
def treeAnnots(tree: untpd.MemberDef): List[Tree] =
6262
val ts = annotTrees.lookup(tree)
@@ -169,9 +169,9 @@ class TreePickler(pickler: TastyPickler) {
169169
def pickleType(tpe0: Type, richTypes: Boolean = false)(using Context): Unit = {
170170
val tpe = tpe0.stripTypeVar
171171
try {
172-
val prev = pickledTypes.get(tpe)
172+
val prev = pickledTypes.lookup(tpe)
173173
if (prev == null) {
174-
pickledTypes.put(tpe, currentAddr)
174+
pickledTypes(tpe) = currentAddr.asInstanceOf[AnyRef]
175175
pickleNewType(tpe, richTypes)
176176
}
177177
else {
@@ -349,7 +349,7 @@ class TreePickler(pickler: TastyPickler) {
349349
docCtx <- ctx.docCtx
350350
comment <- docCtx.docstring(sym)
351351
do
352-
docStrings.enter(mdef, comment)
352+
docStrings(mdef) = comment
353353
}
354354

355355
def pickleParam(tree: Tree)(using Context): Unit = {
@@ -605,7 +605,7 @@ class TreePickler(pickler: TastyPickler) {
605605
else {
606606
val refineCls = refinements.head.symbol.owner.asClass
607607
registerDef(refineCls)
608-
pickledTypes.put(refineCls.typeRef, currentAddr)
608+
pickledTypes(refineCls.typeRef) = currentAddr.asInstanceOf[AnyRef]
609609
writeByte(REFINEDtpt)
610610
refinements.foreach(preRegister)
611611
withLength { pickleTree(parent); refinements.foreach(pickleTree) }
@@ -757,7 +757,7 @@ class TreePickler(pickler: TastyPickler) {
757757
var treeBuf = annotTrees.lookup(mdef)
758758
if treeBuf == null then
759759
treeBuf = new mutable.ListBuffer[Tree]
760-
annotTrees.enter(mdef, treeBuf)
760+
annotTrees(mdef) = treeBuf
761761
treeBuf += ann.tree
762762

763763
// ---- main entry points ---------------------------------------

0 commit comments

Comments
 (0)