From e10d77e1ab3df39dc4a3e36399cb8f477ca5a90c Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 20 Nov 2009 18:59:30 +0000 Subject: More deprecation avoidance and some minor smoot... More deprecation avoidance and some minor smoothings. --- src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala | 11 ++++++++--- .../scala/tools/nsc/interactive/RefinedBuildManager.scala | 4 ++-- src/library/scala/collection/mutable/PriorityQueue.scala | 2 +- src/library/scala/io/UTF8Codec.scala | 2 +- src/library/scala/runtime/RichException.scala | 11 +---------- src/library/scala/xml/TopScope.scala | 2 +- 6 files changed, 14 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala index a5076eb28c..161b09a415 100644 --- a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala +++ b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala @@ -832,6 +832,10 @@ abstract class GenMSIL extends SubComponent { case -1 => xs case idx => x :: (xs take idx) ::: (xs drop (idx + 1)) } + def moveToEnd[T](xs: List[T], x: T) = (xs indexOf x) match { + case -1 => xs + case idx => (xs take idx) ::: (xs drop (idx + 1)) ::: List(x) + } var blocksToPut: List[BasicBlock] = blocks var nextBlock: BasicBlock = null @@ -965,8 +969,9 @@ abstract class GenMSIL extends SubComponent { firstBlockAfter(exh) = outside(0) //else () //assert(firstBlockAfter(exh) == outside(0), "try/catch leaving to multiple targets: " + firstBlockAfter(exh) + ", new: " + outside(0)) + val last = leaving(0)._1 - ((blocks - last) ::: List(last), None) + (moveToEnd(blocks, last), None) } else { val outside = leaving.flatMap(p => p._2) //assert(outside.forall(b => b == outside(0)), "exception-block leaving to multiple targets") @@ -1002,7 +1007,7 @@ abstract class GenMSIL extends SubComponent { h1.addBlock(block) case None => () } - val orderedCatchBlocks = h1.startBlock :: (adaptedBlocks - h1.startBlock) + val orderedCatchBlocks = moveToFront(adaptedBlocks, h1.startBlock) exceptionBlock match { case Some(excBlock) => @@ -1033,7 +1038,7 @@ abstract class GenMSIL extends SubComponent { singleAffectedHandler.finalizer.addBlock(block) case None => () } - val blocks = singleAffectedHandler.finalizer.startBlock :: (blocks0 - singleAffectedHandler.finalizer.startBlock) + val blocks = moveToFront(blocks0, singleAffectedHandler.finalizer.startBlock) currentBlock = excBlock.finallyBlock addBlocks(blocks) } diff --git a/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala b/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala index 05d384cda2..6af23f8fde 100644 --- a/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala +++ b/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala @@ -131,7 +131,7 @@ class RefinedBuildManager(val settings: Settings) extends Changes with BuildMana println("Changes: " + changesOf) updateDefinitions(files) val compiled = updated ++ files - val invalid = invalidated(files, changesOf, additionalDefs ++ compiled) + val invalid = invalidated(files, changesOf, additionalDefs.clone() ++= compiled) update0(invalid -- compiled, compiled) } @@ -224,7 +224,7 @@ class RefinedBuildManager(val settings: Settings) extends Changes with BuildMana if (buf.isEmpty) processed else - invalidated(buf -- processed, newChangesOf, processed ++ buf) + invalidated(buf.clone() --= processed, newChangesOf, processed ++ buf) } /** Update the map of definitions per source file */ diff --git a/src/library/scala/collection/mutable/PriorityQueue.scala b/src/library/scala/collection/mutable/PriorityQueue.scala index aea7f3a567..d6b5d12749 100644 --- a/src/library/scala/collection/mutable/PriorityQueue.scala +++ b/src/library/scala/collection/mutable/PriorityQueue.scala @@ -142,7 +142,7 @@ class PriorityQueue[A](implicit ord: Ordering[A]) * * @param iter an iterable object */ - override def ++(elems: scala.collection.Traversable[A]) = { this.clone() ++= elems } // ??? XXX why does this "override nothing" with override? + override def ++(elems: scala.collection.Traversable[A]) = { this.clone() ++= elems } /** Adds all elements provided by an iterator into the priority queue. * diff --git a/src/library/scala/io/UTF8Codec.scala b/src/library/scala/io/UTF8Codec.scala index 4fac5bca47..ec328700cc 100644 --- a/src/library/scala/io/UTF8Codec.scala +++ b/src/library/scala/io/UTF8Codec.scala @@ -17,7 +17,7 @@ package scala.io object UTF8Codec { final val UNI_REPLACEMENT_CHAR: Int = 0x0000FFFD - final val UNI_REPLACEMENT_BYTES = encode(UNI_REPLACEMENT_CHAR) + final val UNI_REPLACEMENT_BYTES = Array[Byte](-17, -65, -67) // Note, from http://unicode.org/faq/utf_bom.html#utf8-5 // diff --git a/src/library/scala/runtime/RichException.scala b/src/library/scala/runtime/RichException.scala index 27b3c719c6..6bb5d9e627 100644 --- a/src/library/scala/runtime/RichException.scala +++ b/src/library/scala/runtime/RichException.scala @@ -14,14 +14,5 @@ package scala.runtime import compat.Platform.EOL final class RichException(exc: Throwable) { - - def getStackTraceString: String = { - val s = new StringBuilder() - for (trElem <- exc.getStackTrace()) { - s.append(trElem.toString()) - s.append(EOL) - } - s.toString() - } - + def getStackTraceString = exc.getStackTrace().mkString("", EOL, EOL) } diff --git a/src/library/scala/xml/TopScope.scala b/src/library/scala/xml/TopScope.scala index 41a1678a50..e0309757fb 100644 --- a/src/library/scala/xml/TopScope.scala +++ b/src/library/scala/xml/TopScope.scala @@ -16,7 +16,7 @@ import collection.mutable.StringBuilder * for the "xml" prefix which is bound to * "http://www.w3.org/XML/1998/namespace" */ -case object TopScope extends NamespaceBinding(null, null, null) +object TopScope extends NamespaceBinding(null, null, null) { import XML.{ xml, namespace } -- cgit v1.2.3