Skip to content

Commit d8b72b2

Browse files
authored
Merge pull request #3828 from dotty-staging/pickle-less-pos
Avoid pickling the same position multiple times
2 parents 714e5bf + 0c7305a commit d8b72b2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class PositionPickler(pickler: TastyPickler, addrOfTree: tpd.Tree => Option[Addr
1919
import buf._
2020
import ast.tpd._
2121

22-
private val remainingAddrs = new java.util.IdentityHashMap[Tree, Iterator[Addr]]
22+
private val pickledIndices = new mutable.BitSet
2323

2424
def header(addrDelta: Int, hasStartDelta: Boolean, hasEndDelta: Boolean, hasPoint: Boolean) = {
2525
def toInt(b: Boolean) = if (b) 1 else 0
@@ -39,6 +39,8 @@ class PositionPickler(pickler: TastyPickler, addrOfTree: tpd.Tree => Option[Addr
3939
if (!pos.isSynthetic) buf.writeInt(pos.pointDelta)
4040
lastIndex = index
4141
lastPos = pos
42+
43+
pickledIndices += index
4244
}
4345

4446
/** True if x's position shouldn't be reconstructed automatically from its initialPos
@@ -64,7 +66,7 @@ class PositionPickler(pickler: TastyPickler, addrOfTree: tpd.Tree => Option[Addr
6466
val pos = if (x.isInstanceOf[MemberDef]) x.pos else x.pos.toSynthetic
6567
if (pos.exists && (pos != x.initialPos.toSynthetic || alwaysNeedsPos(x))) {
6668
addrOfTree(x) match {
67-
case Some(addr) =>
69+
case Some(addr) if !pickledIndices.contains(addr.index) =>
6870
//println(i"pickling $x with $pos at $addr")
6971
pickleDeltas(addr.index, pos)
7072
case _ =>

0 commit comments

Comments
 (0)