mirror of
https://github.com/dart-lang/sdk
synced 2024-09-20 04:21:32 +00:00
Use strict equality when comparing with null, especially when null is a default value.
Review URL: http://codereview.chromium.org//8400038 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@859 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
acbdba4a71
commit
959f4b519d
|
@ -74,7 +74,7 @@ class Expect {
|
|||
num actual,
|
||||
[num tolerance = null,
|
||||
String reason = null]) {
|
||||
if (tolerance == null) {
|
||||
if (tolerance === null) {
|
||||
tolerance = (expected / Math.pow(10.0, 4.0)).abs();
|
||||
}
|
||||
// Note: use !( <= ) rather than > so we fail on NaNs
|
||||
|
@ -242,7 +242,7 @@ class Expect {
|
|||
}
|
||||
|
||||
static String _getMessage(String reason)
|
||||
=> (reason == null) ? "" : ", '$reason'";
|
||||
=> (reason === null) ? "" : ", '$reason'";
|
||||
|
||||
static void _fail(String message) {
|
||||
throw new ExpectException(message);
|
||||
|
|
|
@ -75,7 +75,7 @@ class FutureImpl<T> implements Future<T> {
|
|||
}
|
||||
|
||||
bool get hasValue() {
|
||||
return isComplete && exception == null;
|
||||
return isComplete && _exception === null;
|
||||
}
|
||||
|
||||
void then(void onComplete(T value)) {
|
||||
|
@ -119,7 +119,7 @@ class FutureImpl<T> implements Future<T> {
|
|||
}
|
||||
|
||||
void _setException(var exception) {
|
||||
if (exception == null) {
|
||||
if (exception === null) {
|
||||
// null is not a legal value for the exception of a Future
|
||||
throw new IllegalArgumentException(null);
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ class PromiseImpl<T> implements Promise<T> {
|
|||
if (_state == COMPLETE_NORMAL) {
|
||||
completeHandler(_value);
|
||||
} else if (!isDone()) {
|
||||
if (_normalListeners == null) {
|
||||
if (_normalListeners === null) {
|
||||
_normalListeners = new Queue<Function>();
|
||||
}
|
||||
_normalListeners.addLast(completeHandler);
|
||||
|
@ -172,7 +172,7 @@ class PromiseImpl<T> implements Promise<T> {
|
|||
if (_state == COMPLETE_ERROR) {
|
||||
errorHandler(_error);
|
||||
} else if (!isDone()) {
|
||||
if (_errorListeners == null) {
|
||||
if (_errorListeners === null) {
|
||||
_errorListeners = new Queue<Function>();
|
||||
}
|
||||
_errorListeners.addLast(errorHandler);
|
||||
|
@ -183,7 +183,7 @@ class PromiseImpl<T> implements Promise<T> {
|
|||
if (isCancelled()) {
|
||||
cancelHandler();
|
||||
} else if (!isDone()) {
|
||||
if (_cancelListeners == null) {
|
||||
if (_cancelListeners === null) {
|
||||
_cancelListeners = new Queue<Function>();
|
||||
}
|
||||
_cancelListeners.addLast(cancelHandler);
|
||||
|
|
|
@ -181,13 +181,13 @@ class SplayTree<K extends Comparable, V> implements Map<K, V> {
|
|||
void forEach(void f(K key, V value)) {
|
||||
List<SplayTreeNode<K, V>> list = new List<SplayTreeNode<K, V>>();
|
||||
SplayTreeNode<K, V> current = _root;
|
||||
while (current != null) {
|
||||
if (current.left != null) {
|
||||
while (current !== null) {
|
||||
if (current.left !== null) {
|
||||
list.add(current);
|
||||
current = current.left;
|
||||
} else {
|
||||
f(current.key, current.value);
|
||||
while (current.right == null) {
|
||||
while (current.right === null) {
|
||||
if (list.isEmpty()) return;
|
||||
current = list.removeLast();
|
||||
f(current.key, current.value);
|
||||
|
|
|
@ -32,8 +32,8 @@ class _FileInputStream implements FileInputStream {
|
|||
}
|
||||
|
||||
int readInto(List<int> buffer, int offset, int len) {
|
||||
if (offset == null) offset = 0;
|
||||
if (len == null) len = buffer.length;
|
||||
if (offset === null) offset = 0;
|
||||
if (len === null) len = buffer.length;
|
||||
if (offset < 0) throw new StreamException("Illegal offset $offset");
|
||||
if (len < 0) throw new StreamException("Illegal length $len");
|
||||
return _file.readListSync(buffer, offset, len);
|
||||
|
|
|
@ -114,7 +114,7 @@ class _Process implements Process {
|
|||
}
|
||||
|
||||
bool kill() {
|
||||
if (_closed && _pid == null) {
|
||||
if (_closed && _pid === null) {
|
||||
throw new ProcessException("Process closed");
|
||||
}
|
||||
if (_killed) {
|
||||
|
|
|
@ -81,7 +81,7 @@ class _SocketBase {
|
|||
}
|
||||
|
||||
int get port() {
|
||||
if (_port == null) {
|
||||
if (_port === null) {
|
||||
_port = _getPort();
|
||||
}
|
||||
return _port;
|
||||
|
@ -96,7 +96,7 @@ class _SocketBase {
|
|||
} else {
|
||||
// This is to support closing sockets created but never assigned
|
||||
// any actual socket.
|
||||
if (_handler == null) {
|
||||
if (_handler === null) {
|
||||
throw new
|
||||
SocketIOException("Error: close failed - invalid socket handle");
|
||||
} else {
|
||||
|
@ -276,14 +276,14 @@ class _Socket extends _SocketBase implements Socket {
|
|||
}
|
||||
|
||||
InputStream get inputStream() {
|
||||
if (_inputStream == null) {
|
||||
if (_inputStream === null) {
|
||||
_inputStream = new SocketInputStream(this);
|
||||
}
|
||||
return _inputStream;
|
||||
}
|
||||
|
||||
OutputStream get outputStream() {
|
||||
if (_outputStream == null) {
|
||||
if (_outputStream === null) {
|
||||
_outputStream = new SocketOutputStream(this);
|
||||
}
|
||||
return _outputStream;
|
||||
|
|
|
@ -29,8 +29,8 @@ class SocketInputStream implements InputStream {
|
|||
}
|
||||
|
||||
int readInto(List<int> buffer, int offset, int len) {
|
||||
if (offset == null) offset = 0;
|
||||
if (len == null) len = buffer.length;
|
||||
if (offset === null) offset = 0;
|
||||
if (len === null) len = buffer.length;
|
||||
if (offset < 0) throw new StreamException("Illegal offset $offset");
|
||||
if (len < 0) throw new StreamException("Illegal length $len");
|
||||
return _socket.readList(buffer, offset, len);
|
||||
|
|
|
@ -171,7 +171,7 @@ class _UTF8Decoder extends _StringDecoderBase {
|
|||
|
||||
class _StringInputStream implements StringInputStream {
|
||||
_StringInputStream(InputStream this._input, [String this._encoding]) {
|
||||
if (_encoding == null) {
|
||||
if (_encoding === null) {
|
||||
_encoding = "UTF-8";
|
||||
}
|
||||
if (_encoding == "UTF-8") {
|
||||
|
@ -213,7 +213,7 @@ class _StringInputStream implements StringInputStream {
|
|||
}
|
||||
// Try to fill more data into the buffer and read a line.
|
||||
if (_fillBuffer()) {
|
||||
if (_eof && _buffer == null) return null;
|
||||
if (_eof && _buffer === null) return null;
|
||||
return _readLineFromBuffer();
|
||||
}
|
||||
return null;
|
||||
|
@ -299,11 +299,11 @@ class _StringInputStream implements StringInputStream {
|
|||
}
|
||||
_readData();
|
||||
var decodedString = _decoder.decoded;
|
||||
if (decodedString == null && _closed) {
|
||||
if (decodedString === null && _closed) {
|
||||
_eof = true;
|
||||
return true;
|
||||
}
|
||||
if (_buffer == null) {
|
||||
if (_buffer === null) {
|
||||
_buffer = decodedString;
|
||||
if (_buffer != null) {
|
||||
_bufferLineStart = 0;
|
||||
|
|
|
@ -135,7 +135,7 @@ class StringBase {
|
|||
}
|
||||
|
||||
String substring(int startIndex, [int endIndex]) {
|
||||
if (endIndex == null) endIndex = this.length;
|
||||
if (endIndex === null) endIndex = this.length;
|
||||
|
||||
if ((startIndex < 0) || (startIndex > this.length)) {
|
||||
throw new IndexOutOfRangeException(startIndex);
|
||||
|
|
|
@ -121,7 +121,7 @@ class Towers {
|
|||
|
||||
TowersDisk pop(int pile) {
|
||||
var top = piles[pile];
|
||||
if (top == null)
|
||||
if (top === null)
|
||||
Error.error("Attempting to remove a disk from an empty pile.");
|
||||
piles[pile] = top.next;
|
||||
top.next = null;
|
||||
|
@ -524,10 +524,10 @@ class TreeNodePress {
|
|||
|
||||
void insert(int n) {
|
||||
if (n < value) {
|
||||
if (left == null) left = new TreeNodePress(n);
|
||||
if (left === null) left = new TreeNodePress(n);
|
||||
else left.insert(n);
|
||||
} else {
|
||||
if (right == null) right = new TreeNodePress(n);
|
||||
if (right === null) right = new TreeNodePress(n);
|
||||
else right.insert(n);
|
||||
}
|
||||
}
|
||||
|
@ -537,8 +537,8 @@ class TreeNodePress {
|
|||
TreeNodePress right = this.right;
|
||||
int value = this.value;
|
||||
|
||||
return ((left == null) || ((left.value < value) && left.check())) &&
|
||||
((right == null) || ((right.value >= value) && right.check()));
|
||||
return ((left === null) || ((left.value < value) && left.check())) &&
|
||||
((right === null) || ((right.value >= value) && right.check()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -609,7 +609,7 @@ class ListElement {
|
|||
ListElement xTail = x;
|
||||
ListElement yTail = y;
|
||||
while (yTail != null) {
|
||||
if (xTail == null) return true;
|
||||
if (xTail === null) return true;
|
||||
xTail = xTail.next;
|
||||
yTail = yTail.next;
|
||||
}
|
||||
|
@ -2137,7 +2137,7 @@ class LineProcessor extends Isolate {
|
|||
void main() {
|
||||
this.port.receive((message, SendPort replyTo) {
|
||||
if (message == MandelIsolateTest.TERMINATION_MESSAGE) {
|
||||
assert(replyTo == null);
|
||||
assert(replyTo === null);
|
||||
this.port.close();
|
||||
} else {
|
||||
replyTo.send(_processLine(message), null);
|
||||
|
|
Loading…
Reference in a new issue