diff options
author | michelou <michelou@epfl.ch> | 2007-04-19 15:45:58 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2007-04-19 15:45:58 +0000 |
commit | a87d9a20e00c4951b774976ef2350d11be764b3d (patch) | |
tree | f92af868f6e5c67210646a72eb7b9f688ab0f0ab /src/library | |
parent | 28edfc11090d9075200dcdd47227b4f067284f9a (diff) | |
download | scala-a87d9a20e00c4951b774976ef2350d11be764b3d.tar.gz scala-a87d9a20e00c4951b774976ef2350d11be764b3d.tar.bz2 scala-a87d9a20e00c4951b774976ef2350d11be764b3d.zip |
updated for-comprehension syntax
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/Array.scala | 30 | ||||
-rw-r--r-- | src/library/scala/List.scala | 26 | ||||
-rw-r--r-- | src/library/scala/Responder.scala | 8 | ||||
-rw-r--r-- | src/library/scala/collection/jcl/Buffer.scala | 10 | ||||
-rw-r--r-- | src/library/scala/runtime/RichException.scala | 7 | ||||
-rw-r--r-- | src/library/scala/runtime/RichString.scala | 6 | ||||
-rw-r--r-- | src/library/scala/testing/Benchmark.scala | 14 | ||||
-rw-r--r-- | src/library/scala/testing/SUnit.scala | 14 | ||||
-rw-r--r-- | src/library/scala/xml/NodeTraverser.scala | 19 | ||||
-rw-r--r-- | src/library/scala/xml/PrettyPrinter.scala | 24 | ||||
-rw-r--r-- | src/library/scala/xml/TextBuffer.scala | 15 | ||||
-rw-r--r-- | src/library/scala/xml/Utility.scala | 31 |
12 files changed, 98 insertions, 106 deletions
diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala index 55c9d4d0a1..aed67110ea 100644 --- a/src/library/scala/Array.scala +++ b/src/library/scala/Array.scala @@ -51,12 +51,10 @@ object Array { */ def concat[T](xs: Array[T]*) = { var len = 0 - for (val x <- xs) { - len += x.length - } + for (x <- xs) len += x.length val result = new Array[T](len) var start = 0 - for (val x <- xs) { + for (x <- xs) { copy(x, 0, result, start, x.length) start += x.length } @@ -71,7 +69,7 @@ object Array { */ def range(start: Int, end: Int): Array[Int] = { val result = new Array[Int](end - start) - for (val i <- Iterator.range(start, end)) result(i - start) = i + for (i <- start until end) result(i - start) = i result } @@ -83,7 +81,7 @@ object Array { def apply[A <: AnyRef](xs: A*): Array[A] = { val array = new Array[A](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } @@ -99,7 +97,7 @@ object Array { def Array[A](xs: A*): Array[A] = { val array = new Array[A](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } */ @@ -107,55 +105,55 @@ object Array { def apply(xs: Boolean*): Array[Boolean] = { val array = new Array[Boolean](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } def apply(xs: Byte*): Array[Byte] = { val array = new Array[Byte](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } def apply(xs: Short*): Array[Short] = { val array = new Array[Short](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } def apply(xs: Char*): Array[Char] = { val array = new Array[Char](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } def apply(xs: Int*): Array[Int] = { val array = new Array[Int](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } def apply(xs: Long*): Array[Long] = { val array = new Array[Long](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } def apply(xs: Float*): Array[Float] = { val array = new Array[Float](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } def apply(xs: Double*): Array[Double] = { val array = new Array[Double](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } def apply(xs: Unit*): Array[Unit] = { val array = new Array[Unit](xs.length) var i = 0 - for (val x <- xs.elements) { array(i) = x; i += 1 } + for (x <- xs.elements) { array(i) = x; i += 1 } array } diff --git a/src/library/scala/List.scala b/src/library/scala/List.scala index e34189cd44..12fce2c20b 100644 --- a/src/library/scala/List.scala +++ b/src/library/scala/List.scala @@ -54,7 +54,7 @@ object List { var i = from while (i < end) { b += i - i = i + step + i += step } b.toList } @@ -71,7 +71,7 @@ object List { var i = from while (i < end) { b += i - i = i + step(i) + i += step(i) } b.toList } @@ -87,7 +87,7 @@ object List { var i = 0 while (i < n) { b += elem - i = i + 1 + i += 1 } b.toList } @@ -106,7 +106,7 @@ object List { var i = 0 while (i < n) { b += maker(i) - i = i + 1 + i += 1 } b.toList } @@ -125,7 +125,7 @@ object List { */ def concat[a](xss: List[a]*): List[a] = { val b = new ListBuffer[a] - for (val xs <- xss) { + for (xs <- xss) { var xc = xs while (!xc.isEmpty) { b += xc.head @@ -180,7 +180,7 @@ object List { var res: List[a] = Nil var i = start + len while (i > start) { - i = i - 1 + i -= 1 res = arr(i) :: res } res @@ -452,7 +452,7 @@ sealed abstract class List[+a] extends Seq[a] { var these = this var len = 0 while (!these.isEmpty) { - len = len + 1 + len += 1 these = these.tail } len @@ -469,7 +469,7 @@ sealed abstract class List[+a] extends Seq[a] { var these = this while (!these.isEmpty) { b += i - i = i + 1 + i += 1 these = these.tail } b.toList @@ -537,7 +537,7 @@ sealed abstract class List[+a] extends Seq[a] { var i = 0 var these = this while (!these.isEmpty && i < n) { - i = i + 1 + i += 1 b += these.head these = these.tail } @@ -592,7 +592,7 @@ sealed abstract class List[+a] extends Seq[a] { var i = 0 var these = this while (!these.isEmpty && i < n) { - i = i + 1 + i += 1 b += these.head these = these.tail } @@ -716,7 +716,7 @@ sealed abstract class List[+a] extends Seq[a] { if (these.isEmpty) this else { val b = new ListBuffer[a] - var these1 = this; + var these1 = this while (these1 ne these) { b += these1.head these1 = these1.tail @@ -839,7 +839,7 @@ sealed abstract class List[+a] extends Seq[a] { var cnt = 0 var these = this while (!these.isEmpty) { - if (p(these.head)) cnt = cnt + 1 + if (p(these.head)) cnt += 1 these = these.tail } cnt @@ -1020,7 +1020,7 @@ sealed abstract class List[+a] extends Seq[a] { while(!these.isEmpty) { b += (these.head, idx) these = these.tail - idx = idx + 1 + idx += 1 } b.toList diff --git a/src/library/scala/Responder.scala b/src/library/scala/Responder.scala index 050caa342e..da9e215ed3 100644 --- a/src/library/scala/Responder.scala +++ b/src/library/scala/Responder.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2005-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -47,10 +47,10 @@ object Responder { } def loop[a](r: Responder[unit]): Responder[Nothing] = - for (val _ <- r; val y <- loop(r)) yield y + for (_ <- r; val y <- loop(r)) yield y def loopWhile[a](cond: => boolean)(r: Responder[unit]): Responder[unit] = - if (cond) for (val _ <- r; val y <- loopWhile(cond)(r)) yield y + if (cond) for (_ <- r; val y <- loopWhile(cond)(r)) yield y else constant(()) } diff --git a/src/library/scala/collection/jcl/Buffer.scala b/src/library/scala/collection/jcl/Buffer.scala index 15033867e9..d7513cc314 100644 --- a/src/library/scala/collection/jcl/Buffer.scala +++ b/src/library/scala/collection/jcl/Buffer.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2006-2007, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -18,18 +18,24 @@ trait Buffer[A] extends MutableSeq[A] with Collection[A] with Ranged[Int,A] { final protected type SortedSelf = Buffer[A]; trait MutableSeqProjection extends super[MutableSeq].Projection; + trait Projection extends MutableSeqProjection with super[Collection].Projection { override def filter(p : A => Boolean) = super[MutableSeqProjection].filter(p); } + override def projection = new Projection {} override def elements : BufferIterator[Int,A]; + /** The first index of a buffer is 0. */ override def first = 0; + /** The last index of a buffer is its size - 1. */ override def last = size - 1; + /** Indices are compared through subtraction. */ final def compare(k0 : Int, k1 : Int) = k0 - k1; + /** Removes the element at index "idx" */ def remove(idx : Int) = { val i = elements; @@ -69,7 +75,7 @@ trait Buffer[A] extends MutableSeq[A] with Collection[A] with Ranged[Int,A] { */ def addAll(idx: Int, that: Iterable[A]): Unit = { val i = elements; i.seek(idx); - for (val that <- that) { + for (that <- that) { i.add(that); i.next; } } diff --git a/src/library/scala/runtime/RichException.scala b/src/library/scala/runtime/RichException.scala index 99f5311446..a9559aa639 100644 --- a/src/library/scala/runtime/RichException.scala +++ b/src/library/scala/runtime/RichException.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -12,14 +12,13 @@ package scala.runtime import Predef._ -import compat.StringBuilder import compat.Platform.EOL final class RichException(exc: Throwable) { def getStackTraceString: String = { val s = new StringBuilder() - for (val trElem <- exc.getStackTrace()) { + for (trElem <- exc.getStackTrace()) { s.append(trElem.toString()) s.append(EOL) } diff --git a/src/library/scala/runtime/RichString.scala b/src/library/scala/runtime/RichString.scala index 375e096631..6786e1e692 100644 --- a/src/library/scala/runtime/RichString.scala +++ b/src/library/scala/runtime/RichString.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -113,7 +113,7 @@ final class RichString(val self: String) extends Proxy with Seq[Char] with Order */ def stripMargin(marginChar: Char): String = { val buf = new scala.compat.StringBuilder() - for (val line <- linesWithSeparators) { + for (line <- linesWithSeparators) { val len = line.length var index = 0; while (index < len && line.charAt(index) <= ' ') index = index + 1 diff --git a/src/library/scala/testing/Benchmark.scala b/src/library/scala/testing/Benchmark.scala index 4d7cc751cf..77c5613572 100644 --- a/src/library/scala/testing/Benchmark.scala +++ b/src/library/scala/testing/Benchmark.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -50,11 +50,11 @@ trait Benchmark { * @return ... */ def runBenchmark(noTimes: Int): List[Long] = - for (val i <- List.range(1, noTimes + 1)) yield { + for (i <- List.range(1, noTimes + 1)) yield { val startTime = Platform.currentTime - var i = 0; while(i < multiplier) { + var i = 0; while (i < multiplier) { run() - i = i + 1 + i += 1 } val stopTime = Platform.currentTime Platform.collectGarbage @@ -70,10 +70,10 @@ trait Benchmark { def main(args: Array[String]): Unit = { if (args.length > 1) { val logFile = new java.io.FileWriter(args(1), true) // append, not overwrite - if(args.length >= 3) + if (args.length >= 3) multiplier = args(2).toInt logFile.write(getClass().getName()) - for (val t <- runBenchmark(args(0).toInt)) + for (t <- runBenchmark(args(0).toInt)) logFile.write("\t\t" + t) logFile.write(Platform.EOL) diff --git a/src/library/scala/testing/SUnit.scala b/src/library/scala/testing/SUnit.scala index 07a7fa0d1b..7c0f76303c 100644 --- a/src/library/scala/testing/SUnit.scala +++ b/src/library/scala/testing/SUnit.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -12,7 +12,6 @@ package scala.testing import scala.collection.mutable.ArrayBuffer -import compat.StringBuilder /** * <p> @@ -36,7 +35,7 @@ import compat.StringBuilder * * <b>val</b> r = <b>new</b> TestResult() * suite.run(r) - * <b>for</b> (<b>val</b> tf <- r.failures()) { + * <b>for</b> (tf <- r.failures()) { * Console.println(tf.toString()) * } * </pre> @@ -56,7 +55,7 @@ object SUnit { def main(args:Array[String]) { val r = new TestResult() suite.run(r) - for (val tf <- r.failures()) + for (tf <- r.failures()) Console.println(tf.toString()) } } @@ -131,10 +130,7 @@ object SUnit { buf += t def run(r: TestResult): Unit = - for(val t <- buf) { - t.run(r) - } - + for (t <- buf) t.run(r) } /** an AssertFailed is thrown for a failed assertion */ diff --git a/src/library/scala/xml/NodeTraverser.scala b/src/library/scala/xml/NodeTraverser.scala index f6fac46bb4..5cbf0aca30 100644 --- a/src/library/scala/xml/NodeTraverser.scala +++ b/src/library/scala/xml/NodeTraverser.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -19,14 +19,17 @@ package scala.xml abstract class NodeTraverser extends parsing.MarkupHandler { def traverse(n: Node): Unit = n match { - case x:ProcInstr => procInstr(0, x.target, x.text) - case x:Comment => comment(0, x.text) - case x:Text => text(0, x.data) - case x:EntityRef => entityRef(0, x.entityName) + case x:ProcInstr => + procInstr(0, x.target, x.text) + case x:Comment => + comment(0, x.text) + case x:Text => + text(0, x.data) + case x:EntityRef => + entityRef(0, x.entityName) case _ => elemStart(0, n.prefix, n.label, n.attributes, n.scope) - for (val m <- n.child) - traverse(m) + for (m <- n.child) traverse(m) elem(0, n.prefix, n.label, n.attributes, n.scope, NodeSeq.fromSeq(n.child)) elemEnd(0, n.prefix, n.label) } diff --git a/src/library/scala/xml/PrettyPrinter.scala b/src/library/scala/xml/PrettyPrinter.scala index 05724ade14..ad3f26c2ed 100644 --- a/src/library/scala/xml/PrettyPrinter.scala +++ b/src/library/scala/xml/PrettyPrinter.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -86,10 +86,10 @@ class PrettyPrinter( width:Int, step:Int ) { if (cur < ind) cur == ind if (cur + s.length() > width) { // fits in this line - items = Box( ind, s ) :: items - cur = cur + s.length() + items = Box(ind, s) :: items + cur += s.length() } else try { - for (val b <- cut(s, ind).elements) // break it up + for (b <- cut(s, ind).elements) // break it up items = b :: items } catch { case _:BrokenException => makePara(ind, s) // give up, para @@ -187,9 +187,9 @@ class PrettyPrinter( width:Int, step:Int ) { val sq:Seq[String] = stg.split(" "); val it = sq.elements; it.next; - for( val c <- it ) { - makeBox( ind+len2-2, c ); - makeBreak(); + for(c <- it) { + makeBox( ind+len2-2, c ); + makeBreak(); } }*/ makeBox(ind, stg.substring(len2, stg.length())) @@ -205,7 +205,7 @@ class PrettyPrinter( width:Int, step:Int ) { } protected def traverse(it: Iterator[Node], scope: NamespaceBinding, ind: Int ): Unit = - for (val c <- it) { + for (c <- it) { traverse(c, scope, ind) makeBreak() } @@ -225,7 +225,7 @@ class PrettyPrinter( width:Int, step:Int ) { reset() traverse(n, pscope, 0) var cur = 0 - for (val b <- items.reverse) b match { + for (b <- items.reverse) b match { case Break => if (!lastwasbreak) sb.append('\n') // on windows: \r\n ? lastwasbreak = true @@ -239,7 +239,7 @@ class PrettyPrinter( width:Int, step:Int ) { lastwasbreak = false while (cur < i) { sb.append(' ') - cur = cur + 1 + cur += 1 } sb.append(s) case Para( s ) => @@ -299,7 +299,7 @@ class PrettyPrinter( width:Int, step:Int ) { * @param sb the string buffer to which to append to */ def formatNodes(nodes: Seq[Node], pscope: NamespaceBinding, sb: StringBuilder): Unit = - for (val n <- nodes.elements) { + for (n <- nodes.elements) { sb.append(format(n, pscope)) } diff --git a/src/library/scala/xml/TextBuffer.scala b/src/library/scala/xml/TextBuffer.scala index 7831b38621..f48d04ece9 100644 --- a/src/library/scala/xml/TextBuffer.scala +++ b/src/library/scala/xml/TextBuffer.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -13,8 +13,7 @@ package scala.xml object TextBuffer { - def fromString(str: String): TextBuffer = - new TextBuffer().append(str) + def fromString(str: String): TextBuffer = new TextBuffer().append(str) } /** The class <code>TextBuffer</code> is for creating text nodes without @@ -36,12 +35,8 @@ class TextBuffer { * @return ... */ def append(cs: Seq[Char]): TextBuffer = { - for (val c <- cs) { - if (Utility.isSpace(c)) - appendSpace - else - appendChar(c) - } + for (c <- cs) + if (Utility.isSpace(c)) appendSpace else appendChar(c) this } @@ -54,7 +49,7 @@ class TextBuffer { if (len == 0) return Nil if (Utility.isSpace(sb.charAt(len - 1))) { - len = len - 1 + len -= 1 sb.setLength(len) } if (len == 0) return Nil diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala index c0b28b89ae..f3cb5f4964 100644 --- a/src/library/scala/xml/Utility.scala +++ b/src/library/scala/xml/Utility.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -11,7 +11,6 @@ package scala.xml -import compat.StringBuilder import collection.mutable.{Set, HashSet} /** @@ -76,7 +75,7 @@ object Utility extends AnyRef with parsing.TokenTests { * @return ... */ final def escape(text: String, s: StringBuilder): StringBuilder = { - for (val c <- Iterator.fromString(text)) c match { + for (c <- Iterator.fromString(text)) c match { case '<' => s.append("<") case '>' => s.append(">") case '&' => s.append("&") @@ -130,13 +129,13 @@ object Utility extends AnyRef with parsing.TokenTests { def collectNamespaces(n: Node, set: Set[String]): Unit = { if (n.typeTag$ >= 0) { set += n.namespace - for (val a <- n.attributes) a match { + for (a <- n.attributes) a match { case _:PrefixedAttribute => set += a.getNamespace(n) case _ => } - for (val i <- n.child) - collectNamespaces(i, set); + for (i <- n.child) + collectNamespaces(i, set) } } @@ -186,17 +185,13 @@ object Utility extends AnyRef with parsing.TokenTests { x.toString(sb) case g: Group => - for (val c <- g.nodes) { - toXML(c, x.scope, sb, stripComment) - } + for (c <- g.nodes) toXML(c, x.scope, sb, stripComment) case _ => // print tag with namespace declarations sb.append('<') x.nameToString(sb) - if (x.attributes ne null) { - x.attributes.toString(sb) - } + if (x.attributes ne null) x.attributes.toString(sb) x.scope.toString(sb, pscope) sb.append('>') sequenceToXML(x.child, pscope, sb, stripComment) @@ -225,8 +220,8 @@ object Utility extends AnyRef with parsing.TokenTests { sb.append(' ') toXML(x, x.scope, sb, stripComment) } - } else for (val c <- children) { - toXML(c, c.scope, sb, stripComment) + } else { + for (c <- children) toXML(c, c.scope, sb, stripComment) } } @@ -238,7 +233,7 @@ object Utility extends AnyRef with parsing.TokenTests { */ final def prefix(name: String): Option[String] = { val i = name.indexOf(':'.asInstanceOf[Int]) - if( i != -1 ) Some( name.substring(0, i) ) else None + if (i != -1) Some(name.substring(0, i)) else None } /** @@ -330,7 +325,7 @@ object Utility extends AnyRef with parsing.TokenTests { */ def appendEscapedQuoted(s: String, sb: StringBuilder) = { sb.append('"') - for (val c <- s) c match { + for (c <- s) c match { case '"' => sb.append('\\'); sb.append('"') case _ => sb.append(c) } @@ -370,7 +365,7 @@ object Utility extends AnyRef with parsing.TokenTests { case '<' => return "< not allowed in attribute value"; case '&' => - val n = getName(value, i+1); + val n = getName(value, i+1) if (n eq null) return "malformed entity reference in attribute value ["+value+"]"; i = i + n.length() + 1 |