diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2016-02-01 14:09:18 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2016-02-01 14:09:18 +1000 |
commit | 6ecb997fa8eb305bf547ec8a6106ba2fd777a594 (patch) | |
tree | aa4138612cbef475817c8db6323b4756973c762b | |
parent | 78f0437ac06e71a94a38721751ef5d36ca62c062 (diff) | |
parent | 0588b495373148574ab381b67f957957930584cf (diff) | |
download | scala-6ecb997fa8eb305bf547ec8a6106ba2fd777a594.tar.gz scala-6ecb997fa8eb305bf547ec8a6106ba2fd777a594.tar.bz2 scala-6ecb997fa8eb305bf547ec8a6106ba2fd777a594.zip |
Merge pull request #4926 from lrytz/scalaTreeMap
mutable.TreeMap instead of java.util.TreeMap in closure optimizer
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/opt/ClosureOptimizer.scala | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/opt/ClosureOptimizer.scala b/src/compiler/scala/tools/nsc/backend/jvm/opt/ClosureOptimizer.scala index 039e6a6d03..b8547e1dc6 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/opt/ClosureOptimizer.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/opt/ClosureOptimizer.scala @@ -75,10 +75,10 @@ class ClosureOptimizer[BT <: BTypes](val btypes: BT) { def rewriteClosureApplyInvocations(): Unit = { // sort all closure invocations to rewrite to ensure bytecode stability - val toRewrite = new java.util.TreeMap[ClosureInstantiation, mutable.ArrayBuffer[(MethodInsnNode, Int)]](closureInitOrdering) + val toRewrite = mutable.TreeMap.empty[ClosureInstantiation, mutable.ArrayBuffer[(MethodInsnNode, Int)]](closureInitOrdering) def addRewrite(init: ClosureInstantiation, invocation: MethodInsnNode, stackHeight: Int): Unit = { - if (!toRewrite.containsKey(init)) toRewrite.put(init, mutable.ArrayBuffer.empty[(MethodInsnNode, Int)]) - toRewrite.get(init) += ((invocation, stackHeight)) + val callsites = toRewrite.getOrElseUpdate(init, mutable.ArrayBuffer.empty[(MethodInsnNode, Int)]) + callsites += ((invocation, stackHeight)) } // For each closure instantiation find callsites of the closure and add them to the toRewrite @@ -113,9 +113,7 @@ class ClosureOptimizer[BT <: BTypes](val btypes: BT) { case _ => } - for (entry <- toRewrite.entrySet.iterator().asScala) { - val closureInit = entry.getKey - val invocations = entry.getValue + for ((closureInit, invocations) <- toRewrite) { // Local variables that hold the captured values and the closure invocation arguments. val (localsForCapturedValues, argumentLocalsList) = localsForClosureRewrite(closureInit) for ((invocation, stackHeight) <- invocations) |