Skip to content

Commit 665f097

Browse files
mihaylovadriaanm
mihaylov
authored andcommitted
Replaced == null()eq null(ne null)
1 parent fe6933b commit 665f097

13 files changed

+24
-24
lines changed

src/library/scala/xml/Elem.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ case class Elem(override val prefix: String,
2828
override val scope: NamespaceBinding,
2929
val child: Node*) extends Node {
3030

31-
if (prefix != null && 0 == prefix.length())
31+
if ((null != prefix) && 0 == prefix.length())
3232
throw new IllegalArgumentException("prefix of zero length, use null instead");
3333

3434
if (null == scope)

src/library/scala/xml/NamespaceBinding.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class NamespaceBinding(val prefix: String,
5959
def toString(sb: StringBuilder, stop: NamespaceBinding): Unit = {
6060
if (this ne stop) { // contains?
6161
sb.append(" xmlns")
62-
if (prefix != null) {
62+
if (prefix ne null) {
6363
sb.append(':').append(prefix)
6464
}
6565
sb.append('=')

src/library/scala/xml/Node.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ abstract class Node extends NodeSeq {
6767
* @return the namespace if <code>scope != null</code> and prefix was
6868
* found, else <code>null</code>
6969
*/
70-
def getNamespace(pre: String) = if (scope == null) null else scope.getURI(pre)
70+
def getNamespace(pre: String) = if (scope eq null) null else scope.getURI(pre)
7171

7272
/**
7373
* Convenience method, looks up an unprefixed attribute in attributes of this node.

src/library/scala/xml/PrefixedAttribute.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class PrefixedAttribute(val pre: String,
2121
val value: Seq[Node],
2222
val next: MetaData) extends MetaData {
2323

24-
if(value == null)
24+
if(value eq null)
2525
throw new UnsupportedOperationException("value is null")
2626

2727
/** same as this(key, Utility.parseAttributeValue(value), next) */
@@ -71,7 +71,7 @@ class PrefixedAttribute(val pre: String,
7171

7272

7373
/** appends string representation of only this attribute to stringbuffer */
74-
def toString1(sb:StringBuilder): Unit = if(value!=null) {
74+
def toString1(sb:StringBuilder): Unit = if(value ne null) {
7575
sb.append(pre)
7676
sb.append(':')
7777
sb.append(key)

src/library/scala/xml/UnprefixedAttribute.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import compat.StringBuilder
1818
*/
1919
class UnprefixedAttribute(val key: String, val value: Seq[Node], next1: MetaData) extends MetaData {
2020

21-
val next = if(value != null) next1 else next1.remove(key)
21+
val next = if(value ne null) next1 else next1.remove(key)
2222

2323
/** same as this(key, Utility.parseAttributeValue(value), next) */
2424
def this(key: String, value: String, next: MetaData) =
25-
this(key, if(value!=null) Text(value) else {val z:NodeSeq=null;z}, next)
25+
this(key, if(value ne null) Text(value) else {val z:NodeSeq=null;z}, next)
2626

2727
/** returns a copy of this unprefixed attribute with the given next field*/
2828
def copy(next: MetaData) =
@@ -58,13 +58,13 @@ class UnprefixedAttribute(val key: String, val value: Seq[Node], next1: MetaData
5858
/** returns the hashcode.
5959
*/
6060
override def hashCode() =
61-
key.hashCode() * 7 + { if(value!=null) value.hashCode() * 53 else 0 } + next.hashCode()
61+
key.hashCode() * 7 + { if(value ne null) value.hashCode() * 53 else 0 } + next.hashCode()
6262

6363
/** returns false */
6464
final def isPrefixed = false
6565

6666
/** appends string representation of only this attribute to stringbuffer */
67-
def toString1(sb:StringBuilder): Unit = if(value!=null) {
67+
def toString1(sb:StringBuilder): Unit = if(value ne null) {
6868
sb.append(key)
6969
sb.append('=')
7070
val sb2 = new StringBuilder()

src/library/scala/xml/Utility.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ object Utility extends AnyRef with parsing.TokenTests {
159159
// print tag with namespace declarations
160160
sb.append('<')
161161
x.nameToString(sb)
162-
if (x.attributes != null) {
162+
if (x.attributes ne null) {
163163
x.attributes.toString(sb)
164164
}
165165
x.scope.toString(sb, pscope)
@@ -215,7 +215,7 @@ object Utility extends AnyRef with parsing.TokenTests {
215215
* @param children
216216
*/
217217
def hashCode(pre: String, label: String, attribHashCode: Int, scpeHash: Int, children: Seq[Node]) = {
218-
( if(pre!=null) {41 * pre.hashCode() % 7} else {0})
218+
( if(pre ne null) {41 * pre.hashCode() % 7} else {0})
219219
+ label.hashCode() * 53
220220
+ attribHashCode * 7
221221
+ scpeHash * 31
@@ -337,7 +337,7 @@ object Utility extends AnyRef with parsing.TokenTests {
337337
return "< not allowed in attribute value";
338338
case '&' =>
339339
val n = getName(value, i+1);
340-
if (n == null)
340+
if (n eq null)
341341
return "malformed entity reference in attribute value ["+value+"]";
342342
i = i + n.length() + 1
343343
if (i >= value.length() || value.charAt(i) != ';')
@@ -372,7 +372,7 @@ object Utility extends AnyRef with parsing.TokenTests {
372372
sb.append(theChar)
373373

374374
case x =>
375-
if (rfb==null) rfb = new StringBuilder()
375+
if (rfb eq null) rfb = new StringBuilder()
376376
rfb.append(x)
377377
c = it.next
378378
while (c != ';') {

src/library/scala/xml/XML.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ object XML {
151151
final def write(w: java.io.Writer, node: Node, enc: String, xmlDecl: Boolean, doctype: dtd.DocType): Unit = {
152152
/* TODO: optimize by giving writer parameter to toXML*/
153153
if (xmlDecl) w.write("<?xml version='1.0' encoding='" + enc + "'?>\n")
154-
if (doctype != null) w.write( doctype.toString() + "\n")
154+
if (doctype ne null) w.write( doctype.toString() + "\n")
155155
w.write(Utility.toXML(node))
156156
}
157157
}

src/library/scala/xml/dtd/ElementValidator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class ElementValidator() extends Function1[Node,Boolean] {
5757

5858
}
5959
case _ =>
60-
x.namespace == null
60+
x.namespace eq null
6161
}}
6262
. map { x => ElemName(x.label) }
6363
. elements;

src/library/scala/xml/dtd/ExternalID.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ case class PublicID( publicId:String, systemId:String ) extends ExternalID with
6666
throw new IllegalArgumentException(
6767
"publicId must consist of PubidChars"
6868
)
69-
if( systemId != null && !checkSysID( systemId ) )
69+
if( (systemId ne null) && !checkSysID( systemId ) )
7070
throw new IllegalArgumentException(
7171
"can't use both \" and ' in systemId"
7272
)
@@ -83,7 +83,7 @@ case class PublicID( publicId:String, systemId:String ) extends ExternalID with
8383
/** appends "PUBLIC "+publicId+" SYSTEM "+systemId to argument */
8484
override def toString(sb: StringBuilder): StringBuilder = {
8585
Utility.publicLiteralToString( sb, publicId ).append(' ')
86-
if(systemId!=null)
86+
if(systemId ne null)
8787
Utility.systemLiteralToString( sb, systemId )
8888
else
8989
sb

src/library/scala/xml/parsing/ExternalSources.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ trait ExternalSources requires (ExternalSources with MarkupParser with MarkupHan
3030
var inputLine:String = null;
3131

3232
//while (inputLine = in.readLine()) != null) {
33-
while ({inputLine = in.readLine(); inputLine} != null) {
33+
while ({inputLine = in.readLine(); inputLine} ne null) {
3434
// Console.println(inputLine); // DEBUG
3535
str.append(inputLine);
3636
str.append('\n'); // readable output

src/library/scala/xml/parsing/FactoryAdapter.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ abstract class FactoryAdapter extends DefaultHandler() {
188188
// reverse order to get it right
189189
var v: List[Node] = Nil
190190
var child: Node = hStack.pop
191-
while (child != null) {
191+
while (child ne null) {
192192
v = child::v
193193
child = hStack.pop
194194
}
@@ -209,7 +209,7 @@ abstract class FactoryAdapter extends DefaultHandler() {
209209
curTag = tagStack.pop
210210

211211
capture =
212-
if (curTag != null) nodeContainsText(curTag) // root level
212+
if (curTag ne null) nodeContainsText(curTag) // root level
213213
else false
214214
} // endElement(String,String,String)
215215

@@ -243,7 +243,7 @@ abstract class FactoryAdapter extends DefaultHandler() {
243243
Console.print("] ")
244244

245245
var systemId = ex.getSystemId()
246-
if (systemId != null) {
246+
if (systemId ne null) {
247247
val index = systemId.lastIndexOf('/'.asInstanceOf[Int])
248248
if (index != -1)
249249
systemId = systemId.substring(index + 1)

src/library/scala/xml/parsing/MarkupParser.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ trait MarkupParser requires (MarkupParser with MarkupHandler) extends AnyRef wit
580580
def parseDTD(): Unit = { // dirty but fast
581581
//Console.println("(DEBUG) parseDTD");
582582
var extID: ExternalID = null
583-
if (this.dtd != null)
583+
if (this.dtd ne null)
584584
reportSyntaxError("unexpected character (DOCTYPE already defined");
585585
xToken("DOCTYPE")
586586
xSpace
@@ -649,7 +649,7 @@ trait MarkupParser requires (MarkupParser with MarkupHandler) extends AnyRef wit
649649
/*override val */decls = handle.decls.reverse
650650
}
651651
//this.dtd.initializeEntities();
652-
if (doc!=null)
652+
if (doc ne null)
653653
doc.dtd = this.dtd
654654

655655
handle.endDTD(n)

src/library/scala/xml/pull/XMLEventReader.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class XMLEventReader extends Iterator[XMLEvent] {
5959
notifyAll
6060
}
6161
def getAndClearEvent: XMLEvent = synchronized {
62-
while(xmlEvent == null) {
62+
while(xmlEvent eq null) {
6363
wait()
6464
}
6565
val r = xmlEvent

0 commit comments

Comments
 (0)