Skip to content

Avoid pickling the same position multiple times #3828

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PositionPickler(pickler: TastyPickler, addrOfTree: tpd.Tree => Option[Addr
import buf._
import ast.tpd._

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

def header(addrDelta: Int, hasStartDelta: Boolean, hasEndDelta: Boolean, hasPoint: Boolean) = {
def toInt(b: Boolean) = if (b) 1 else 0
Expand All @@ -39,6 +39,8 @@ class PositionPickler(pickler: TastyPickler, addrOfTree: tpd.Tree => Option[Addr
if (!pos.isSynthetic) buf.writeInt(pos.pointDelta)
lastIndex = index
lastPos = pos

pickledIndices += index
}

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