summaryrefslogtreecommitdiff
path: root/src/detach/plugin
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-07-14 01:27:04 +0000
committerPaul Phillips <paulp@improving.org>2011-07-14 01:27:04 +0000
commit733669230a470b60c2ecc92c666f0871cecf22ef (patch)
tree70ee5f0e49e348e317bfd9db5d2230b433dada31 /src/detach/plugin
parent5e49b4181976f20d28625008a775223dbf8e7f6e (diff)
downloadscala-733669230a470b60c2ecc92c666f0871cecf22ef.tar.gz
scala-733669230a470b60c2ecc92c666f0871cecf22ef.tar.bz2
scala-733669230a470b60c2ecc92c666f0871cecf22ef.zip
Adding some Sets/Maps to perRunCaches, and elim...
Adding some Sets/Maps to perRunCaches, and eliminating ambiguously named imports. Did a tour of the compiler adding a few longer-lived mutable structures to the per-run cache clearing mechanism. Some of these were not a big threat, but there is (almost) literally no cost to tracking them and the fewer mutable structures which are created "lone wolf style" the easier it is to spot the one playing by his own rules. While I was at it I followed through on long held ambition to eliminate the importing of highly ambiguous names like "Map" and "HashSet" from the mutable and immutable packages. I didn't quite manage elimination but it's pretty close. Something potentially as pernicious which I didn't do much about is this import: import scala.collection._ Imagine coming across that one on lines 407 and 474 of a 1271 file. That's not cool. Some poor future programmer will be on line 1100 and use "Map[A, B]" in some function and only after the product has shipped will it be discovered that the signature is wrong and the rocket will now be crashing into the mountainside straightaway. No review.
Diffstat (limited to 'src/detach/plugin')
-rw-r--r--src/detach/plugin/scala/tools/detach/Detach.scala37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/detach/plugin/scala/tools/detach/Detach.scala b/src/detach/plugin/scala/tools/detach/Detach.scala
index 56433cd33e..e9cd474b82 100644
--- a/src/detach/plugin/scala/tools/detach/Detach.scala
+++ b/src/detach/plugin/scala/tools/detach/Detach.scala
@@ -5,9 +5,8 @@
package scala.tools.detach
-import scala.collection.immutable
-import scala.collection.mutable.{HashMap, HashSet, ListBuffer}
-
+import scala.collection.{ mutable, immutable }
+import scala.collection.mutable.ListBuffer
import scala.tools.nsc._
import scala.tools.nsc.plugins.PluginComponent
import scala.tools.nsc.symtab.Flags._
@@ -116,23 +115,23 @@ abstract class Detach extends PluginComponent
private val remoteRefClass = immutable.HashMap(elems(""): _*)
private val remoteRefImpl = immutable.HashMap(elems("Impl"): _*)
- private val proxyInterfaceDefs = new HashMap[Symbol/*owner*/, ListBuffer[Tree]]
- private val detachedClosureApply = new HashMap[Tree, Apply]
+ private val proxyInterfaceDefs = new mutable.HashMap[Symbol/*owner*/, ListBuffer[Tree]]
+ private val detachedClosureApply = new mutable.HashMap[Tree, Apply]
- private type SymSet = HashSet[Symbol]
- private val capturedObjects = new HashMap[Symbol/*clazz*/, SymSet]
- private val capturedFuncs = new HashMap[Symbol/*clazz*/, SymSet]
- private val capturedCallers = new HashMap[Symbol/*clazz*/, SymSet]
- private val capturedThisClass = new HashMap[Symbol, Symbol]
+ private type SymSet = mutable.HashSet[Symbol]
+ private val capturedObjects = new mutable.HashMap[Symbol/*clazz*/, SymSet]
+ private val capturedFuncs = new mutable.HashMap[Symbol/*clazz*/, SymSet]
+ private val capturedCallers = new mutable.HashMap[Symbol/*clazz*/, SymSet]
+ private val capturedThisClass = new mutable.HashMap[Symbol, Symbol]
- private val proxies = new HashMap[
+ private val proxies = new mutable.HashMap[
Symbol, //clazz
- (Symbol, Symbol, HashMap[Symbol, Symbol]) //iface, impl, accessor map
+ (Symbol, Symbol, mutable.HashMap[Symbol, Symbol]) //iface, impl, accessor map
]
def toInterface(clazz: Symbol) = proxies(clazz)._1
- private val classdefs = new HashMap[Symbol/*clazz*/, ClassDef]
+ private val classdefs = new mutable.HashMap[Symbol/*clazz*/, ClassDef]
// detachedClosure gathers class definitions containing a "detach" apply
- private val detachedClosure = new HashMap[Symbol/*clazz*/, ClassDef]
+ private val detachedClosure = new mutable.HashMap[Symbol/*clazz*/, ClassDef]
/** <p>
* The method <code>freeObjTraverser.traverse</code> is invoked
@@ -146,9 +145,9 @@ abstract class Detach extends PluginComponent
* </p>
*/
private val freeObjTraverser = new Traverser {
- def symSet(f: HashMap[Symbol, SymSet], sym: Symbol): SymSet = f.get(sym) match {
+ def symSet(f: mutable.HashMap[Symbol, SymSet], sym: Symbol): SymSet = f.get(sym) match {
case Some(ss) => ss
- case None => val ss = new HashSet[Symbol]; f(sym) = ss; ss
+ case None => val ss = new mutable.HashSet[Symbol]; f(sym) = ss; ss
}
def getClosureApply(tree: Tree): Apply = tree match {
case Block(_, expr) => getClosureApply(expr)
@@ -255,7 +254,7 @@ abstract class Detach extends PluginComponent
println("\nTreeOuterSubstituter:"+
"\n\tfrom="+from.mkString(",")+
"\n\tto="+to.mkString(","))
- val substMap = new HashMap[Symbol, Symbol]
+ val substMap = new mutable.HashMap[Symbol, Symbol]
override def traverse(tree: Tree) {
def subst(from: List[Symbol], to: List[Symbol]) {
if (!from.isEmpty)
@@ -328,7 +327,7 @@ abstract class Detach extends PluginComponent
}
subst(sym.tpe)
}
- val map = new HashMap[Symbol, Symbol]
+ val map = new mutable.HashMap[Symbol, Symbol]
override def traverse(tree: Tree) {
if (tree.hasSymbol && tree.symbol != NoSymbol) {
val sym = tree.symbol
@@ -751,7 +750,7 @@ abstract class Detach extends PluginComponent
//val cparents = List(ObjectClass.tpe, iface.tpe,
// UnreferencedClass.tpe, ScalaObjectClass.tpe)
iclaz setInfo ClassInfoType(cparents, new Scope, iclaz)
- val proxy = (iface, iclaz, new HashMap[Symbol, Symbol])
+ val proxy = (iface, iclaz, new mutable.HashMap[Symbol, Symbol])
proxies(clazz) = proxy
proxy
}