diff options
author | Paul Phillips <paulp@improving.org> | 2011-07-14 01:27:04 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-07-14 01:27:04 +0000 |
commit | 733669230a470b60c2ecc92c666f0871cecf22ef (patch) | |
tree | 70ee5f0e49e348e317bfd9db5d2230b433dada31 /src/swing | |
parent | 5e49b4181976f20d28625008a775223dbf8e7f6e (diff) | |
download | scala-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/swing')
-rw-r--r-- | src/swing/scala/swing/ButtonGroup.scala | 5 | ||||
-rw-r--r-- | src/swing/scala/swing/LayoutContainer.scala | 4 | ||||
-rw-r--r-- | src/swing/scala/swing/Publisher.scala | 12 | ||||
-rw-r--r-- | src/swing/scala/swing/UIElement.scala | 3 |
4 files changed, 8 insertions, 16 deletions
diff --git a/src/swing/scala/swing/ButtonGroup.scala b/src/swing/scala/swing/ButtonGroup.scala index bfecea0092..b2e37848cb 100644 --- a/src/swing/scala/swing/ButtonGroup.scala +++ b/src/swing/scala/swing/ButtonGroup.scala @@ -6,14 +6,11 @@ ** |/ ** \* */ - - package scala.swing import event._ import javax.swing.{AbstractButton => JAbstractButton,Icon} -import scala.collection._ -import scala.collection.mutable.Buffer +import scala.collection.{ mutable, immutable } /** * A button mutex. At most one of its associated buttons is selected diff --git a/src/swing/scala/swing/LayoutContainer.scala b/src/swing/scala/swing/LayoutContainer.scala index 0e4a1af41b..0865abf595 100644 --- a/src/swing/scala/swing/LayoutContainer.scala +++ b/src/swing/scala/swing/LayoutContainer.scala @@ -11,7 +11,7 @@ package scala.swing import javax.swing.JComponent -import scala.collection.mutable.Map +import scala.collection.mutable /** <p> * A container that associates layout constraints of member type @@ -57,7 +57,7 @@ trait LayoutContainer extends Container.Wrapper { * * also ensures that myComponent is properly added to this container. */ - def layout: Map[Component, Constraints] = new Map[Component, Constraints] { + def layout: mutable.Map[Component, Constraints] = new mutable.Map[Component, Constraints] { def -= (c: Component): this.type = { _contents -= c; this } def += (cl: (Component, Constraints)): this.type = { update(cl._1, cl._2); this } override def update (c: Component, l: Constraints) { diff --git a/src/swing/scala/swing/Publisher.scala b/src/swing/scala/swing/Publisher.scala index 3c3e99fc49..6ce38df0e9 100644 --- a/src/swing/scala/swing/Publisher.scala +++ b/src/swing/scala/swing/Publisher.scala @@ -6,12 +6,10 @@ ** |/ ** \* */ - - package scala.swing -import scala.collection._ -import scala.collection.mutable.{Buffer, HashSet, Set} +import scala.collection.mutable +import mutable.Buffer import event.Event /** <p> @@ -33,7 +31,7 @@ trait Publisher extends Reactor { protected val listeners = new RefSet[Reaction] { import scala.ref._ - val underlying = new HashSet[Reference[Reaction]] + val underlying = new mutable.HashSet[Reference[Reaction]] protected def Ref(a: Reaction) = a match { case a: StronglyReferenced => new StrongReference[Reaction](a) with super.Ref[Reaction] case _ => new WeakReference[Reaction](a, referenceQueue) with super.Ref[Reaction] @@ -164,8 +162,8 @@ abstract class RefBuffer[A <: AnyRef] extends Buffer[A] with SingleRefCollection protected[this] def removeReference(ref: Reference[A]) { underlying -= ref } } -private[swing] abstract class RefSet[A <: AnyRef] extends Set[A] with SingleRefCollection[A] { self => - protected val underlying: Set[Reference[A]] +private[swing] abstract class RefSet[A <: AnyRef] extends mutable.Set[A] with SingleRefCollection[A] { self => + protected val underlying: mutable.Set[Reference[A]] def -=(el: A): this.type = { underlying -= Ref(el); purgeReferences(); this } def +=(el: A): this.type = { purgeReferences(); underlying += Ref(el); this } diff --git a/src/swing/scala/swing/UIElement.scala b/src/swing/scala/swing/UIElement.scala index 9c5120a342..048568dda2 100644 --- a/src/swing/scala/swing/UIElement.scala +++ b/src/swing/scala/swing/UIElement.scala @@ -6,13 +6,10 @@ ** |/ ** \* */ - - package scala.swing import java.awt.Cursor import event._ -import scala.collection.mutable.HashMap import scala.ref._ import java.util.WeakHashMap |