diff options
author | mihaylov <mihaylov@epfl.ch> | 2006-11-13 14:59:18 +0000 |
---|---|---|
committer | mihaylov <mihaylov@epfl.ch> | 2006-11-13 14:59:18 +0000 |
commit | f3047df95f007d48d0049ff78448d27045b20445 (patch) | |
tree | 47e848f238fad00e117a4244ec69c229945301df /src/library | |
parent | ac255eaf858397ee14b8ffafd8066b100d5e6be4 (diff) | |
download | scala-f3047df95f007d48d0049ff78448d27045b20445.tar.gz scala-f3047df95f007d48d0049ff78448d27045b20445.tar.bz2 scala-f3047df95f007d48d0049ff78448d27045b20445.zip |
Replaced == null()eq null(ne null)
Diffstat (limited to 'src/library')
31 files changed, 83 insertions, 83 deletions
diff --git a/src/library/scala/Application.scala b/src/library/scala/Application.scala index 9b268abeae..672969e91c 100644 --- a/src/library/scala/Application.scala +++ b/src/library/scala/Application.scala @@ -50,7 +50,7 @@ trait Application { * @param args the arguments passed to the main method */ def main(args: Array[String]) = { - if (getProperty("scala.time") != null) { + if (getProperty("scala.time") ne null) { val total = currentTime - executionStart Console.println("[total " + total + "ms]") } diff --git a/src/library/scala/BigInt.scala b/src/library/scala/BigInt.scala index 8efad433b1..9be8a45dbd 100644 --- a/src/library/scala/BigInt.scala +++ b/src/library/scala/BigInt.scala @@ -32,7 +32,7 @@ object BigInt { def apply(i: Int): BigInt = if (minCached <= i && i <= maxCached) { var n = cache(i) - if (n == null) { n = new BigInt(BigInteger.valueOf(i)); cache(i) = n } + if (n eq null) { n = new BigInt(BigInteger.valueOf(i)); cache(i) = n } n } else new BigInt(BigInteger.valueOf(i)) diff --git a/src/library/scala/Console.scala b/src/library/scala/Console.scala index 8fa4285ab6..7cc8e9d4e9 100644 --- a/src/library/scala/Console.scala +++ b/src/library/scala/Console.scala @@ -142,7 +142,7 @@ object Console { * @param obj the object to print. */ def print(obj: Any): Unit = - out.print(if (obj == null) "null" else obj.toString()) + out.print(if (null == obj) "null" else obj.toString()) /** Flush the output stream. This function is required when partial * output (i.e. output not terminated by a new line character) has @@ -173,7 +173,7 @@ object Console { // todo: Uncurry def printf(text: String)(args: Any*): Unit = out.print( - if (text == null) "null" + if (text eq null) "null" else MessageFormat.format(text, textParams(args)) ) diff --git a/src/library/scala/Enumeration.scala b/src/library/scala/Enumeration.scala index b92ad6ca4e..cff1c41238 100644 --- a/src/library/scala/Enumeration.scala +++ b/src/library/scala/Enumeration.scala @@ -66,7 +66,7 @@ abstract class Enumeration(initial: Int, names: String*) { private var vcache: List[Value] = null private def updateCache: List[Value] = - if (vcache == null) { + if (vcache eq null) { vcache = values.values.toList.sort((p1, p2) => p1.id < p2.id); vcache } else @@ -132,7 +132,7 @@ abstract class Enumeration(initial: Int, names: String*) { topId = nextId def id = i override def toString() = - if (name == null) Enumeration.this.name + "(" + i + ")" + if (name eq null) Enumeration.this.name + "(" + i + ")" else name } } diff --git a/src/library/scala/MatchError.scala b/src/library/scala/MatchError.scala index 6ef969b97c..57ada9efbd 100644 --- a/src/library/scala/MatchError.scala +++ b/src/library/scala/MatchError.scala @@ -24,7 +24,7 @@ import Predef._ object MatchError { def string(obj: Any) = - if(obj != null) obj.toString() else "null" + if (null != obj) obj.toString() else "null" // todo: change pattern matcher so that dummy type parameter T can be removed. def fail[T](source: String, line: Int): Nothing = diff --git a/src/library/scala/collection/mutable/DoubleLinkedList.scala b/src/library/scala/collection/mutable/DoubleLinkedList.scala index f2916d39e9..5ed7a5dbb8 100644 --- a/src/library/scala/collection/mutable/DoubleLinkedList.scala +++ b/src/library/scala/collection/mutable/DoubleLinkedList.scala @@ -28,24 +28,24 @@ abstract class DoubleLinkedList[A, This >: Null <: DoubleLinkedList[A, This]] var prev: This override def append(that: This): Unit = - if (that == null) + if (that eq null) () - else if (next == null) { + else if (next eq null) { next = that that.prev = this } else next.append(that) - override def insert(that: This): Unit = if (that != null) { + override def insert(that: This): Unit = if (that ne null) { that.append(next) next = that that.prev = this } def remove: Unit = { - if (next != null) + if (next ne null) next.prev = prev - if (prev != null) + if (prev ne null) prev.next = next prev = null next = null diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala index 5ec6e6eb7c..1c248835e9 100644 --- a/src/library/scala/collection/mutable/ListBuffer.scala +++ b/src/library/scala/collection/mutable/ListBuffer.scala @@ -248,7 +248,7 @@ final class ListBuffer[A] extends Buffer[A] { if (!hasNext) { throw new NoSuchElementException("next on empty Iterator") } else { - if (cursor == null) cursor = start else cursor = cursor.tail + if (cursor eq null) cursor = start else cursor = cursor.tail cursor.head } } diff --git a/src/library/scala/collection/mutable/MutableList.scala b/src/library/scala/collection/mutable/MutableList.scala index 6e57074641..8983949aaa 100644 --- a/src/library/scala/collection/mutable/MutableList.scala +++ b/src/library/scala/collection/mutable/MutableList.scala @@ -69,12 +69,12 @@ trait MutableList[A] extends Seq[A] with PartialFunction[Int, A] { /** Returns an iterator over all elements of this list. */ def elements: Iterator[A] = - if (first == null) Nil.elements else first.elements + if (first eq null) Nil.elements else first.elements /** Returns an instance of <code>scala.List</code> containing the same * sequence of elements. */ - override def toList: List[A] = if (first == null) Nil else first.toList + override def toList: List[A] = if (first eq null) Nil else first.toList override protected def stringPrefix: String = "MutableList" } diff --git a/src/library/scala/collection/mutable/Queue.scala b/src/library/scala/collection/mutable/Queue.scala index 7d31b2b66e..271c8d680d 100644 --- a/src/library/scala/collection/mutable/Queue.scala +++ b/src/library/scala/collection/mutable/Queue.scala @@ -27,7 +27,7 @@ class Queue[A] extends MutableList[A] { * * @return true, iff there is no element in the queue. */ - override def isEmpty: Boolean = (first == null) + override def isEmpty: Boolean = (first eq null) /** Inserts a single element at the end of the queue. * @@ -64,12 +64,12 @@ class Queue[A] extends MutableList[A] { * @return the first element of the queue. */ def dequeue: A = - if (first == null) + if (first eq null) throw new NoSuchElementException("queue empty") else { val res = first.elem first = first.next - if (first == null) last = null + if (first eq null) last = null len = len - 1 res } @@ -81,15 +81,15 @@ class Queue[A] extends MutableList[A] { * @return the first element of the queue for which p yields true */ def dequeueFirst(p: A => Boolean): Option[A] = - if (first == null) + if (first eq null) None else if (p(first.elem)) { val res: Option[A] = Some(first.elem) first = first.next len = len - 1 - if (first == null) { + if (first eq null) { last = null - } else if (first.next == null) { + } else if (first.next eq null) { last = first } res @@ -108,16 +108,16 @@ class Queue[A] extends MutableList[A] { */ def dequeueAll(p: A => Boolean): Seq[A] = { val res = new ArrayBuffer[A] - if (first == null) + if (first eq null) res else { while (p(first.elem)) { res += first.elem first = first.next len = len - 1 - if (first == null) { + if (first eq null) { last = null - } else if (first.next == null) { + } else if (first.next eq null) { last = first } } @@ -132,15 +132,15 @@ class Queue[A] extends MutableList[A] { private def extractFirst(start: LinkedList[A], p: A => Boolean): Option[LinkedList[A]] = { var cell = start - while ((cell.next != null) && !p(cell.next.elem)) { + while ((cell.next ne null) && !p(cell.next.elem)) { cell = cell.next } - if (cell.next == null) + if (cell.next eq null) None else { val res: Option[LinkedList[A]] = Some(cell.next) cell.next = cell.next.next - if (cell.next == null) + if (cell.next eq null) last = cell len = len - 1 res diff --git a/src/library/scala/collection/mutable/SingleLinkedList.scala b/src/library/scala/collection/mutable/SingleLinkedList.scala index 6a889fc49e..2fc51ad9a2 100644 --- a/src/library/scala/collection/mutable/SingleLinkedList.scala +++ b/src/library/scala/collection/mutable/SingleLinkedList.scala @@ -28,29 +28,29 @@ abstract class SingleLinkedList[A, This >: Null <: SingleLinkedList[A, This]] var next: This - def length: Int = 1 + (if (next == null) 0 else next.length) + def length: Int = 1 + (if (next eq null) 0 else next.length) def append(that: This): Unit = - if (next == null) next = that else next.append(that) + if (next eq null) next = that else next.append(that) - def insert(that: This): Unit = if (that != null) { + def insert(that: This): Unit = if (that ne null) { that.append(next) next = that } def apply(n: Int): A = if (n == 0) elem - else if (next == null) throw new IndexOutOfBoundsException("unknown element") + else if (next eq null) throw new IndexOutOfBoundsException("unknown element") else next.apply(n - 1) def get(n: Int): Option[A] = if (n == 0) Some(elem) - else if (next == null) None + else if (next eq null) None else next.get(n - 1) def elements: Iterator[A] = new Iterator[A] { var elems = SingleLinkedList.this - def hasNext = (elems != null) + def hasNext = (elems ne null) def next = { val res = elems.elem elems = elems.next diff --git a/src/library/scala/collection/mutable/Stack.scala b/src/library/scala/collection/mutable/Stack.scala index 825e87c629..e3aa316c21 100644 --- a/src/library/scala/collection/mutable/Stack.scala +++ b/src/library/scala/collection/mutable/Stack.scala @@ -25,7 +25,7 @@ class Stack[A] extends MutableList[A] { * * @return true, iff there is no element on the stack */ - override def isEmpty: Boolean = (first == null) + override def isEmpty: Boolean = (first eq null) /** Pushes a single element on top of the stack. * @@ -63,7 +63,7 @@ class Stack[A] extends MutableList[A] { * @throws Predef.NoSuchElementException * @return the top element */ - def top: A = if (first == null) throw new NoSuchElementException("stack empty") else first.elem + def top: A = if (first eq null) throw new NoSuchElementException("stack empty") else first.elem /** Removes the top element from the stack. * @@ -71,7 +71,7 @@ class Stack[A] extends MutableList[A] { * @return the top element */ def pop: A = - if (first != null) { + if (first ne null) { val res = first.elem first = first.next len = len - 1; diff --git a/src/library/scala/concurrent/Actor.scala b/src/library/scala/concurrent/Actor.scala index 8f2534bb95..15b77bf3fd 100644 --- a/src/library/scala/concurrent/Actor.scala +++ b/src/library/scala/concurrent/Actor.scala @@ -37,7 +37,7 @@ abstract class Actor extends Thread { private var pid: Pid = null def self = { - if (pid == null) pid = new Pid(this) + if (pid eq null) pid = new Pid(this) pid } diff --git a/src/library/scala/concurrent/Channel.scala b/src/library/scala/concurrent/Channel.scala index f7a156271f..bab6345ab9 100644 --- a/src/library/scala/concurrent/Channel.scala +++ b/src/library/scala/concurrent/Channel.scala @@ -36,7 +36,7 @@ class Channel[a] { } def read: a = synchronized { - if (written.next == null) { + if (null == written.next) { nreaders = nreaders + 1; wait(); nreaders = nreaders - 1 } val x = written.elem diff --git a/src/library/scala/concurrent/MailBox.scala b/src/library/scala/concurrent/MailBox.scala index 7a8b4eac20..e1399e9e58 100644 --- a/src/library/scala/concurrent/MailBox.scala +++ b/src/library/scala/concurrent/MailBox.scala @@ -31,13 +31,13 @@ class MailBox extends AnyRef with ListQueueCreator { def isDefinedAt(msg: Message) = receiver.isDefinedAt(msg) def receive(): a = synchronized { - while (msg == null) wait() + while (msg eq null) wait() receiver(msg) } def receiveWithin(msec: long): a = synchronized { - if (msg == null) wait(msec) - receiver(if (msg != null) msg else TIMEOUT) + if (msg eq null) wait(msec) + receiver(if (msg ne null) msg else TIMEOUT) } } @@ -157,13 +157,13 @@ trait LinkedListQueueCreator { def extractFirst(l: t, p: a => boolean): Option[Pair[a, t]] = { var xs = l._1 var xs1 = xs.next - while (xs1 != null && !p(xs1.elem)) { + while ((xs1 ne null) && !p(xs1.elem)) { xs = xs1 xs1 = xs1.next } - if (xs1 != null) { + if (xs1 ne null) { xs.next = xs1.next - if (xs.next == null) + if (xs.next eq null) Some(Pair(xs1.elem, Pair(l._1, xs))) else Some(Pair(xs1.elem, l)) diff --git a/src/library/scala/mobile/Code.scala b/src/library/scala/mobile/Code.scala index e7166bfc1a..33ddc8f6fa 100644 --- a/src/library/scala/mobile/Code.scala +++ b/src/library/scala/mobile/Code.scala @@ -185,7 +185,7 @@ class Code(clazz: java.lang.Class) { val method = clazz.getMethod(methName, argTypes) var obj: JObject = null if (! Modifier.isStatic(method.getModifiers())) { - if (instance == null) { + if (instance eq null) { instance = try { clazz.newInstance() } catch { case _ => @@ -202,7 +202,7 @@ class Code(clazz: java.lang.Class) { obj = instance } val result = method.invoke(obj, args) - if (result == null) ().asInstanceOf[JObject] else result + if (result eq null) ().asInstanceOf[JObject] else result } catch { case me: NoSuchMethodException => diff --git a/src/library/scala/mobile/Location.scala b/src/library/scala/mobile/Location.scala index 246db26fc9..2b8d456ea5 100644 --- a/src/library/scala/mobile/Location.scala +++ b/src/library/scala/mobile/Location.scala @@ -41,7 +41,7 @@ class Location(url: URL) { /** The class loader associated with this location. */ - private val loader = if (url == null) + private val loader = if (url eq null) ClassLoader.getSystemClassLoader() else lcache.get(url) match { diff --git a/src/library/scala/runtime/BoxedAnyArray.scala b/src/library/scala/runtime/BoxedAnyArray.scala index 558c01dead..7242e5763a 100644 --- a/src/library/scala/runtime/BoxedAnyArray.scala +++ b/src/library/scala/runtime/BoxedAnyArray.scala @@ -28,7 +28,7 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray { private var elemClass: Class = null def apply(index: Int): AnyRef = synchronized { - if (unboxed == null) + if (unboxed eq null) boxed(index); else if (elemClass eq ScalaRunTime.IntTYPE) Int.box(unboxed.asInstanceOf[Array[Int]](index)) @@ -51,7 +51,7 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray { } def update(index: Int, elem: AnyRef): Unit = synchronized { - if (unboxed == null) + if (unboxed eq null) boxed(index) = elem else if (elemClass eq ScalaRunTime.IntTYPE) unboxed.asInstanceOf[Array[Int]](index) = Int.unbox(elem) @@ -85,7 +85,7 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray { else unbox(Platform.getClassForName(elemTag)) def unbox(elemClass: Class): AnyRef = synchronized { - if (unboxed == null) { + if (unboxed eq null) { this.elemClass = elemClass; if (elemClass eq ScalaRunTime.IntTYPE) { val newvalue = new Array[Int](length) @@ -165,21 +165,21 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray { override def equals(other: Any): Boolean = ( other.isInstanceOf[BoxedAnyArray] && (this eq (other.asInstanceOf[BoxedAnyArray])) || - (if (unboxed == null) boxed == other else unboxed == other) + (if (unboxed eq null) boxed == other else unboxed == other) ) override def hashCode(): Int = hash def value: AnyRef = { - if (unboxed == null) throw new NotDefinedError("BoxedAnyArray.value") + if (unboxed eq null) throw new NotDefinedError("BoxedAnyArray.value") unboxed } private def adapt(other: AnyRef): AnyRef = - if (this.unboxed == null) + if (this.unboxed eq null) other match { case that: BoxedAnyArray => - if (that.unboxed == null) { + if (that.unboxed eq null) { that.boxed } else { if (ScalaRunTime.isValueClass(that.elemClass)) unbox(that.elemClass); @@ -209,7 +209,7 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray { else other match { case that: BoxedAnyArray => - if (that.unboxed != null) that.unboxed + if (that.unboxed ne null) that.unboxed else if (ScalaRunTime.isValueClass(this.elemClass)) that.unbox(this.elemClass) else that.boxed case that: BoxedArray => @@ -220,12 +220,12 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray { override def copyFrom(src: AnyRef, from: Int, to: Int, len: Int): Unit = { val src1 = adapt(src) - Array.copy(src1, from, if (unboxed != null) unboxed else boxed, to, len) + Array.copy(src1, from, if (unboxed ne null) unboxed else boxed, to, len) } override def copyTo(from: Int, dest: AnyRef, to: Int, len: Int): Unit = { var dest1 = adapt(dest) - Array.copy(if (unboxed != null) unboxed else boxed, from, dest1, to, len) + Array.copy(if (unboxed ne null) unboxed else boxed, from, dest1, to, len) } override def subArray(start: Int, end: Int): AnyRef = { diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index 7173253316..f0b5eb3ddc 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -52,7 +52,7 @@ object ScalaRunTime { def run(): Unit = result = block; def Catch[b >: a](handler: PartialFunction[Throwable, b]): b = - if (exception == null) + if (exception eq null) result.asInstanceOf[b] // !!! else if (exception is LocalReturn) // !!! // ... @@ -62,7 +62,7 @@ object ScalaRunTime { throw exception; def Finally(handler: Unit): a = - if (exception == null) + if (exception eq null) result.asInstanceOf[a] else throw exception; diff --git a/src/library/scala/xml/Elem.scala b/src/library/scala/xml/Elem.scala index 96b571c505..77941f1c60 100644 --- a/src/library/scala/xml/Elem.scala +++ b/src/library/scala/xml/Elem.scala @@ -28,7 +28,7 @@ case class Elem(override val prefix: String, override val scope: NamespaceBinding, val child: Node*) extends Node { - if (prefix != null && 0 == prefix.length()) + if ((null != prefix) && 0 == prefix.length()) throw new IllegalArgumentException("prefix of zero length, use null instead"); if (null == scope) diff --git a/src/library/scala/xml/NamespaceBinding.scala b/src/library/scala/xml/NamespaceBinding.scala index 0a3f860803..c1acb444e5 100644 --- a/src/library/scala/xml/NamespaceBinding.scala +++ b/src/library/scala/xml/NamespaceBinding.scala @@ -59,7 +59,7 @@ class NamespaceBinding(val prefix: String, def toString(sb: StringBuilder, stop: NamespaceBinding): Unit = { if (this ne stop) { // contains? sb.append(" xmlns") - if (prefix != null) { + if (prefix ne null) { sb.append(':').append(prefix) } sb.append('=') diff --git a/src/library/scala/xml/Node.scala b/src/library/scala/xml/Node.scala index 141a9f9f1b..e9d233af13 100644 --- a/src/library/scala/xml/Node.scala +++ b/src/library/scala/xml/Node.scala @@ -67,7 +67,7 @@ abstract class Node extends NodeSeq { * @return the namespace if <code>scope != null</code> and prefix was * found, else <code>null</code> */ - def getNamespace(pre: String) = if (scope == null) null else scope.getURI(pre) + def getNamespace(pre: String) = if (scope eq null) null else scope.getURI(pre) /** * Convenience method, looks up an unprefixed attribute in attributes of this node. diff --git a/src/library/scala/xml/PrefixedAttribute.scala b/src/library/scala/xml/PrefixedAttribute.scala index 96ba45c73c..397a68507c 100644 --- a/src/library/scala/xml/PrefixedAttribute.scala +++ b/src/library/scala/xml/PrefixedAttribute.scala @@ -21,7 +21,7 @@ class PrefixedAttribute(val pre: String, val value: Seq[Node], val next: MetaData) extends MetaData { - if(value == null) + if(value eq null) throw new UnsupportedOperationException("value is null") /** same as this(key, Utility.parseAttributeValue(value), next) */ @@ -71,7 +71,7 @@ class PrefixedAttribute(val pre: String, /** appends string representation of only this attribute to stringbuffer */ - def toString1(sb:StringBuilder): Unit = if(value!=null) { + def toString1(sb:StringBuilder): Unit = if(value ne null) { sb.append(pre) sb.append(':') sb.append(key) diff --git a/src/library/scala/xml/UnprefixedAttribute.scala b/src/library/scala/xml/UnprefixedAttribute.scala index 5159c5a67f..8f08da3696 100644 --- a/src/library/scala/xml/UnprefixedAttribute.scala +++ b/src/library/scala/xml/UnprefixedAttribute.scala @@ -18,11 +18,11 @@ import compat.StringBuilder */ class UnprefixedAttribute(val key: String, val value: Seq[Node], next1: MetaData) extends MetaData { - val next = if(value != null) next1 else next1.remove(key) + val next = if(value ne null) next1 else next1.remove(key) /** same as this(key, Utility.parseAttributeValue(value), next) */ def this(key: String, value: String, next: MetaData) = - this(key, if(value!=null) Text(value) else {val z:NodeSeq=null;z}, next) + this(key, if(value ne null) Text(value) else {val z:NodeSeq=null;z}, next) /** returns a copy of this unprefixed attribute with the given next field*/ def copy(next: MetaData) = @@ -58,13 +58,13 @@ class UnprefixedAttribute(val key: String, val value: Seq[Node], next1: MetaData /** returns the hashcode. */ override def hashCode() = - key.hashCode() * 7 + { if(value!=null) value.hashCode() * 53 else 0 } + next.hashCode() + key.hashCode() * 7 + { if(value ne null) value.hashCode() * 53 else 0 } + next.hashCode() /** returns false */ final def isPrefixed = false /** appends string representation of only this attribute to stringbuffer */ - def toString1(sb:StringBuilder): Unit = if(value!=null) { + def toString1(sb:StringBuilder): Unit = if(value ne null) { sb.append(key) sb.append('=') val sb2 = new StringBuilder() diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala index fdc6681b5c..2788fd9529 100644 --- a/src/library/scala/xml/Utility.scala +++ b/src/library/scala/xml/Utility.scala @@ -159,7 +159,7 @@ object Utility extends AnyRef with parsing.TokenTests { // print tag with namespace declarations sb.append('<') x.nameToString(sb) - if (x.attributes != null) { + if (x.attributes ne null) { x.attributes.toString(sb) } x.scope.toString(sb, pscope) @@ -215,7 +215,7 @@ object Utility extends AnyRef with parsing.TokenTests { * @param children */ def hashCode(pre: String, label: String, attribHashCode: Int, scpeHash: Int, children: Seq[Node]) = { - ( if(pre!=null) {41 * pre.hashCode() % 7} else {0}) + ( if(pre ne null) {41 * pre.hashCode() % 7} else {0}) + label.hashCode() * 53 + attribHashCode * 7 + scpeHash * 31 @@ -337,7 +337,7 @@ object Utility extends AnyRef with parsing.TokenTests { return "< not allowed in attribute value"; case '&' => val n = getName(value, i+1); - if (n == null) + if (n eq null) return "malformed entity reference in attribute value ["+value+"]"; i = i + n.length() + 1 if (i >= value.length() || value.charAt(i) != ';') @@ -372,7 +372,7 @@ object Utility extends AnyRef with parsing.TokenTests { sb.append(theChar) case x => - if (rfb==null) rfb = new StringBuilder() + if (rfb eq null) rfb = new StringBuilder() rfb.append(x) c = it.next while (c != ';') { diff --git a/src/library/scala/xml/XML.scala b/src/library/scala/xml/XML.scala index 673c44d333..e9e51ca520 100644 --- a/src/library/scala/xml/XML.scala +++ b/src/library/scala/xml/XML.scala @@ -151,7 +151,7 @@ object XML { final def write(w: java.io.Writer, node: Node, enc: String, xmlDecl: Boolean, doctype: dtd.DocType): Unit = { /* TODO: optimize by giving writer parameter to toXML*/ if (xmlDecl) w.write("<?xml version='1.0' encoding='" + enc + "'?>\n") - if (doctype != null) w.write( doctype.toString() + "\n") + if (doctype ne null) w.write( doctype.toString() + "\n") w.write(Utility.toXML(node)) } } diff --git a/src/library/scala/xml/dtd/ElementValidator.scala b/src/library/scala/xml/dtd/ElementValidator.scala index 19406c577d..645caa66eb 100644 --- a/src/library/scala/xml/dtd/ElementValidator.scala +++ b/src/library/scala/xml/dtd/ElementValidator.scala @@ -57,7 +57,7 @@ class ElementValidator() extends Function1[Node,Boolean] { } case _ => - x.namespace == null + x.namespace eq null }} . map { x => ElemName(x.label) } . elements; diff --git a/src/library/scala/xml/dtd/ExternalID.scala b/src/library/scala/xml/dtd/ExternalID.scala index 304c8b01e0..514db9c60f 100644 --- a/src/library/scala/xml/dtd/ExternalID.scala +++ b/src/library/scala/xml/dtd/ExternalID.scala @@ -66,7 +66,7 @@ case class PublicID( publicId:String, systemId:String ) extends ExternalID with throw new IllegalArgumentException( "publicId must consist of PubidChars" ) - if( systemId != null && !checkSysID( systemId ) ) + if( (systemId ne null) && !checkSysID( systemId ) ) throw new IllegalArgumentException( "can't use both \" and ' in systemId" ) @@ -83,7 +83,7 @@ case class PublicID( publicId:String, systemId:String ) extends ExternalID with /** appends "PUBLIC "+publicId+" SYSTEM "+systemId to argument */ override def toString(sb: StringBuilder): StringBuilder = { Utility.publicLiteralToString( sb, publicId ).append(' ') - if(systemId!=null) + if(systemId ne null) Utility.systemLiteralToString( sb, systemId ) else sb diff --git a/src/library/scala/xml/parsing/ExternalSources.scala b/src/library/scala/xml/parsing/ExternalSources.scala index d3fd41314d..90b7f406a4 100644 --- a/src/library/scala/xml/parsing/ExternalSources.scala +++ b/src/library/scala/xml/parsing/ExternalSources.scala @@ -30,7 +30,7 @@ trait ExternalSources requires (ExternalSources with MarkupParser with MarkupHan var inputLine:String = null; //while (inputLine = in.readLine()) != null) { - while ({inputLine = in.readLine(); inputLine} != null) { + while ({inputLine = in.readLine(); inputLine} ne null) { // Console.println(inputLine); // DEBUG str.append(inputLine); str.append('\n'); // readable output diff --git a/src/library/scala/xml/parsing/FactoryAdapter.scala b/src/library/scala/xml/parsing/FactoryAdapter.scala index 99d81aef72..d1deabb5a2 100644 --- a/src/library/scala/xml/parsing/FactoryAdapter.scala +++ b/src/library/scala/xml/parsing/FactoryAdapter.scala @@ -188,7 +188,7 @@ abstract class FactoryAdapter extends DefaultHandler() { // reverse order to get it right var v: List[Node] = Nil var child: Node = hStack.pop - while (child != null) { + while (child ne null) { v = child::v child = hStack.pop } @@ -209,7 +209,7 @@ abstract class FactoryAdapter extends DefaultHandler() { curTag = tagStack.pop capture = - if (curTag != null) nodeContainsText(curTag) // root level + if (curTag ne null) nodeContainsText(curTag) // root level else false } // endElement(String,String,String) @@ -243,7 +243,7 @@ abstract class FactoryAdapter extends DefaultHandler() { Console.print("] ") var systemId = ex.getSystemId() - if (systemId != null) { + if (systemId ne null) { val index = systemId.lastIndexOf('/'.asInstanceOf[Int]) if (index != -1) systemId = systemId.substring(index + 1) diff --git a/src/library/scala/xml/parsing/MarkupParser.scala b/src/library/scala/xml/parsing/MarkupParser.scala index c3a69b555a..e1813fdac5 100644 --- a/src/library/scala/xml/parsing/MarkupParser.scala +++ b/src/library/scala/xml/parsing/MarkupParser.scala @@ -580,7 +580,7 @@ trait MarkupParser requires (MarkupParser with MarkupHandler) extends AnyRef wit def parseDTD(): Unit = { // dirty but fast //Console.println("(DEBUG) parseDTD"); var extID: ExternalID = null - if (this.dtd != null) + if (this.dtd ne null) reportSyntaxError("unexpected character (DOCTYPE already defined"); xToken("DOCTYPE") xSpace @@ -649,7 +649,7 @@ trait MarkupParser requires (MarkupParser with MarkupHandler) extends AnyRef wit /*override val */decls = handle.decls.reverse } //this.dtd.initializeEntities(); - if (doc!=null) + if (doc ne null) doc.dtd = this.dtd handle.endDTD(n) diff --git a/src/library/scala/xml/pull/XMLEventReader.scala b/src/library/scala/xml/pull/XMLEventReader.scala index b89bdb764d..130d7afe19 100644 --- a/src/library/scala/xml/pull/XMLEventReader.scala +++ b/src/library/scala/xml/pull/XMLEventReader.scala @@ -59,7 +59,7 @@ class XMLEventReader extends Iterator[XMLEvent] { notifyAll } def getAndClearEvent: XMLEvent = synchronized { - while(xmlEvent == null) { + while(xmlEvent eq null) { wait() } val r = xmlEvent |