Cleanup unused vars in VM patch files
Change-Id: Ibc548921113d979df5b0ed8eb7f6ad48a553fc86
Reviewed-on: https://dart-review.googlesource.com/c/84121
Commit-Queue: Kevin Moore <kevmoo@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
diff --git a/pkg/build_integration/pubspec.yaml b/pkg/build_integration/pubspec.yaml
index a8c5bef..b746b5c 100644
--- a/pkg/build_integration/pubspec.yaml
+++ b/pkg/build_integration/pubspec.yaml
@@ -5,5 +5,8 @@
# This package is not intended to be published - yet
publish_to: none
+environment:
+ sdk: '>=2.0.0 <3.0.0'
+
dependencies:
front_end: ^0.1.0
diff --git a/pkg/vm/pubspec.yaml b/pkg/vm/pubspec.yaml
index c1ba691..ef74ee0 100644
--- a/pkg/vm/pubspec.yaml
+++ b/pkg/vm/pubspec.yaml
@@ -6,8 +6,8 @@
dependencies:
build_integration:
path: ../build_integration
- front_end: 0.1.6
- kernel: 0.3.6
+ front_end: ^0.1.6
+ kernel: ^0.3.6
dev_dependencies:
args: ^1.4.4
diff --git a/runtime/lib/async_patch.dart b/runtime/lib/async_patch.dart
index 0cd4bd8..c293221 100644
--- a/runtime/lib/async_patch.dart
+++ b/runtime/lib/async_patch.dart
@@ -200,8 +200,7 @@
// If stream is cancelled, tell caller to exit the async generator.
if (!controller.hasListener) return true;
isAdding = true;
- var whenDoneAdding =
- controller.addStream(stream as Stream<T>, cancelOnError: false);
+ var whenDoneAdding = controller.addStream(stream, cancelOnError: false);
whenDoneAdding.then((_) {
isAdding = false;
scheduleGenerator();
diff --git a/runtime/lib/bigint_patch.dart b/runtime/lib/bigint_patch.dart
index 0ae7425..0341923 100644
--- a/runtime/lib/bigint_patch.dart
+++ b/runtime/lib/bigint_patch.dart
@@ -2572,9 +2572,6 @@
// args[_rhoDigit.._rhoHighDigit] =
// 1/args[_xDigit.._xHighDigit] mod _digitBase^2.
static void _invDigitPair(Uint32List args) {
- var two = _BigIntImpl.two;
- var mask32 = _BigIntImpl._oneDigitMask;
- var mask64 = _BigIntImpl._twoDigitMask;
var xl = args[_xDigit]; // Lower 32-bit digit of x.
var y = xl & 3; // y == 1/x mod 2^2
y = (y * (2 - (xl & 0xf) * y)) & 0xf; // y == 1/x mod 2^4
diff --git a/runtime/lib/collection_patch.dart b/runtime/lib/collection_patch.dart
index 05cf6e1..664f619 100644
--- a/runtime/lib/collection_patch.dart
+++ b/runtime/lib/collection_patch.dart
@@ -34,17 +34,11 @@
identical(identical, equals)) {
return new _IdentityHashMap<K, V>();
}
- if (equals == null) {
- equals = _defaultEquals;
- }
+ equals ??= _defaultEquals;
}
} else {
- if (hashCode == null) {
- hashCode = _defaultHashCode;
- }
- if (equals == null) {
- equals = _defaultEquals;
- }
+ hashCode ??= _defaultHashCode;
+ equals ??= _defaultEquals;
}
return new _CustomHashMap<K, V>(equals, hashCode, isValidKey);
}
@@ -536,17 +530,11 @@
identical(identical, equals)) {
return new _IdentityHashSet<E>();
}
- if (equals == null) {
- equals = _defaultEquals;
- }
+ equals ??= _defaultEquals;
}
} else {
- if (hashCode == null) {
- hashCode = _defaultHashCode;
- }
- if (equals == null) {
- equals = _defaultEquals;
- }
+ hashCode ??= _defaultHashCode;
+ equals ??= _defaultEquals;
}
return new _CustomHashSet<E>(equals, hashCode, isValidKey);
}
@@ -637,9 +625,7 @@
}
void addAll(Iterable<E> objects) {
- int ctr = 0;
for (E object in objects) {
- ctr++;
add(object);
}
}
@@ -879,17 +865,11 @@
identical(identical, equals)) {
return new _CompactLinkedIdentityHashMap<K, V>();
}
- if (equals == null) {
- equals = _defaultEquals;
- }
+ equals ??= _defaultEquals;
}
} else {
- if (hashCode == null) {
- hashCode = _defaultHashCode;
- }
- if (equals == null) {
- equals = _defaultEquals;
- }
+ hashCode ??= _defaultHashCode;
+ equals ??= _defaultEquals;
}
return new _CompactLinkedCustomHashMap<K, V>(equals, hashCode, isValidKey);
}
@@ -916,17 +896,11 @@
identical(identical, equals)) {
return new _CompactLinkedIdentityHashSet<E>();
}
- if (equals == null) {
- equals = _defaultEquals;
- }
+ equals ??= _defaultEquals;
}
} else {
- if (hashCode == null) {
- hashCode = _defaultHashCode;
- }
- if (equals == null) {
- equals = _defaultEquals;
- }
+ hashCode ??= _defaultHashCode;
+ equals ??= _defaultEquals;
}
return new _CompactLinkedCustomHashSet<E>(equals, hashCode, isValidKey);
}
diff --git a/runtime/lib/compact_hash.dart b/runtime/lib/compact_hash.dart
index c374ec6..20ddf7a 100644
--- a/runtime/lib/compact_hash.dart
+++ b/runtime/lib/compact_hash.dart
@@ -256,7 +256,6 @@
void operator []=(K key, V value) {
final int size = _index.length;
- final int sizeMask = size - 1;
final int fullHash = _hashCode(key);
final int hashPattern = _HashBase._hashPattern(fullHash, _hashMask, size);
final int d = _findValueOrInsertPoint(key, fullHash, hashPattern, size);
@@ -270,8 +269,6 @@
V putIfAbsent(K key, V ifAbsent()) {
final int size = _index.length;
- final int sizeMask = size - 1;
- final int maxEntries = size >> 1;
final int fullHash = _hashCode(key);
final int hashPattern = _HashBase._hashPattern(fullHash, _hashMask, size);
final int d = _findValueOrInsertPoint(key, fullHash, hashPattern, size);
diff --git a/runtime/lib/convert_patch.dart b/runtime/lib/convert_patch.dart
index 6ba8444..0802cbb 100644
--- a/runtime/lib/convert_patch.dart
+++ b/runtime/lib/convert_patch.dart
@@ -177,7 +177,6 @@
}
void arrayElement() {
- List list = currentContainer;
currentContainer.add(value);
value = null;
}
diff --git a/runtime/lib/date_patch.dart b/runtime/lib/date_patch.dart
index 7f811cf..1899e0c 100644
--- a/runtime/lib/date_patch.dart
+++ b/runtime/lib/date_patch.dart
@@ -57,7 +57,7 @@
@patch
DateTime._now()
: isUtc = false,
- _value = _getCurrentMicros() {}
+ _value = _getCurrentMicros();
@patch
String get timeZoneName {
@@ -180,9 +180,7 @@
}
get _parts {
- if (__parts == null) {
- __parts = _computeUpperPart(_localDateInUtcMicros);
- }
+ __parts ??= _computeUpperPart(_localDateInUtcMicros);
return __parts;
}
diff --git a/runtime/lib/developer.dart b/runtime/lib/developer.dart
index 96577e1..12ad8b7 100644
--- a/runtime/lib/developer.dart
+++ b/runtime/lib/developer.dart
@@ -35,9 +35,7 @@
if (message is! String) {
throw new ArgumentError.value(message, "message", "Must be a String");
}
- if (time == null) {
- time = new DateTime.now();
- }
+ time ??= new DateTime.now();
if (time is! DateTime) {
throw new ArgumentError.value(time, "time", "Must be a DateTime");
}
diff --git a/runtime/lib/function.dart b/runtime/lib/function.dart
index 8a47f00..ae3902a 100644
--- a/runtime/lib/function.dart
+++ b/runtime/lib/function.dart
@@ -9,9 +9,7 @@
bool operator ==(Object other) native "Closure_equals";
int get hashCode {
- if (_hash == null) {
- _hash = _computeHash();
- }
+ _hash ??= _computeHash();
return _hash;
}
diff --git a/runtime/lib/growable_array.dart b/runtime/lib/growable_array.dart
index d23632f..0dbe008 100644
--- a/runtime/lib/growable_array.dart
+++ b/runtime/lib/growable_array.dart
@@ -224,7 +224,6 @@
if (length == 1) return this[0];
if (length == 0) throw IterableElementError.noElement();
throw IterableElementError.tooMany();
- ;
}
// Shared array used as backing for new empty growable arrays.
diff --git a/runtime/lib/isolate_patch.dart b/runtime/lib/isolate_patch.dart
index 0767bb6..972d9af 100644
--- a/runtime/lib/isolate_patch.dart
+++ b/runtime/lib/isolate_patch.dart
@@ -458,7 +458,7 @@
packageRootString,
packageConfigString);
return await _spawnCommon(readyPort);
- } catch (e, st) {
+ } catch (e) {
if (readyPort != null) {
readyPort.close();
}
@@ -632,7 +632,7 @@
static Uri _getCurrentRootUri() {
try {
return Uri.parse(_getCurrentRootUriStr());
- } catch (e, s) {
+ } catch (e) {
return null;
}
}
diff --git a/runtime/lib/lib_prefix.dart b/runtime/lib/lib_prefix.dart
index 8b1fed1..c895931 100644
--- a/runtime/lib/lib_prefix.dart
+++ b/runtime/lib/lib_prefix.dart
@@ -54,7 +54,6 @@
// which have not completed, remember them for next time in
// stillOutstandingLoadRequests.
var stillOutstandingLoadRequests = new List<List>();
- var completedLoadRequests = new List<List>();
// Make a copy of the outstandingRequests because the call to _load below
// may recursively trigger another call to |_completeDeferredLoads|, which
diff --git a/runtime/lib/math_patch.dart b/runtime/lib/math_patch.dart
index 73eb844..fb68674 100644
--- a/runtime/lib/math_patch.dart
+++ b/runtime/lib/math_patch.dart
@@ -245,7 +245,7 @@
static const _POW2_27_D = 1.0 * (1 << 27);
// Use a singleton Random object to get a new seed if no seed was passed.
- static var _prng = new _Random._withState(_initialSeed());
+ static final _prng = new _Random._withState(_initialSeed());
// This is a native to prevent 64-bit operations in Dart, which
// fail with --throw_on_javascript_int_overflow.
diff --git a/runtime/lib/string_patch.dart b/runtime/lib/string_patch.dart
index fe749e4..103959b 100644
--- a/runtime/lib/string_patch.dart
+++ b/runtime/lib/string_patch.dart
@@ -124,7 +124,6 @@
if (charCodes == null) throw new ArgumentError(charCodes);
// TODO(srdjan): Also skip copying of wide typed arrays.
final ccid = ClassID.getID(charCodes);
- bool isOneByteString = false;
if ((ccid != ClassID.cidArray) &&
(ccid != ClassID.cidGrowableObjectArray) &&
(ccid != ClassID.cidImmutableArray)) {
@@ -139,9 +138,7 @@
end = RangeError.checkValidRange(start, end, codeCount);
final len = end - start;
if (len == 0) return "";
- if (limit == null) {
- limit = _scanCodeUnits(charCodes, start, end);
- }
+ limit ??= _scanCodeUnits(charCodes, start, end);
if (limit < 0) {
throw new ArgumentError(charCodes);
}
@@ -368,7 +365,7 @@
}
String substring(int startIndex, [int endIndex]) {
- if (endIndex == null) endIndex = this.length;
+ endIndex ??= this.length;
if ((startIndex < 0) || (startIndex > this.length)) {
throw new RangeError.value(startIndex);
@@ -623,7 +620,6 @@
int replacementLength = replacement.length;
int startIndex = 0;
if (replacementLength == 0) {
- int count = 0;
for (Match match in pattern.allMatches(this)) {
length += _addReplaceSlice(matches, startIndex, match.start);
startIndex = match.end;
@@ -782,8 +778,8 @@
if (pattern is! Pattern) {
throw new ArgumentError("${pattern} is not a Pattern");
}
- if (onMatch == null) onMatch = _matchString;
- if (onNonMatch == null) onNonMatch = _stringIdentity;
+ onMatch ??= _matchString;
+ onNonMatch ??= _stringIdentity;
if (pattern is String) {
String stringPattern = pattern;
if (stringPattern.isEmpty) {
diff --git a/runtime/lib/timer_impl.dart b/runtime/lib/timer_impl.dart
index 89cb6cd..01db53f 100644
--- a/runtime/lib/timer_impl.dart
+++ b/runtime/lib/timer_impl.dart
@@ -124,7 +124,7 @@
// Timers are ordered by wakeup time. Timers with a timeout value of > 0 do
// end up on the TimerHeap. Timers with a timeout of 0 are queued in a list.
- static _TimerHeap _heap = new _TimerHeap();
+ static final _heap = new _TimerHeap();
static _Timer _firstZeroTimer;
static _Timer _lastZeroTimer;
diff --git a/runtime/lib/timer_patch.dart b/runtime/lib/timer_patch.dart
index 3104ecb..88940ff 100644
--- a/runtime/lib/timer_patch.dart
+++ b/runtime/lib/timer_patch.dart
@@ -26,9 +26,7 @@
static Timer _createPeriodicTimer(
Duration duration, void callback(Timer timer)) {
// TODO(iposva): Remove _TimerFactory and use VMLibraryHooks exclusively.
- if (_TimerFactory._factory == null) {
- _TimerFactory._factory = VMLibraryHooks.timerFactory;
- }
+ _TimerFactory._factory ??= VMLibraryHooks.timerFactory;
if (_TimerFactory._factory == null) {
throw new UnsupportedError("Timer interface not supported.");
}
diff --git a/runtime/lib/typed_data_patch.dart b/runtime/lib/typed_data_patch.dart
index 7387c96..9c5f7d6 100644
--- a/runtime/lib/typed_data_patch.dart
+++ b/runtime/lib/typed_data_patch.dart
@@ -165,7 +165,7 @@
}
void shuffle([Random random]) {
- if (random == null) random = new Random();
+ random ??= new Random();
var i = this.length;
while (i > 1) {
int pos = random.nextInt(i);
@@ -282,7 +282,6 @@
int reduce(int combine(int value, int element)) {
var len = this.length;
if (len == 0) throw IterableElementError.noElement();
- var i = 0;
var value = this[0];
for (var i = 1; i < len; ++i) {
value = combine(value, this[i]);
@@ -330,7 +329,6 @@
}
int lastWhere(bool test(int element), {int orElse()}) {
- var result = null;
var len = this.length;
for (var i = len - 1; i >= 0; --i) {
var element = this[i];
@@ -518,7 +516,7 @@
}
void shuffle([Random random]) {
- if (random == null) random = new Random();
+ random ??= new Random();
var i = this.length;
while (i > 1) {
int pos = random.nextInt(i);
@@ -637,7 +635,6 @@
double reduce(double combine(double value, double element)) {
var len = this.length;
if (len == 0) throw IterableElementError.noElement();
- var i = 0;
var value = this[0];
for (var i = 1; i < len; ++i) {
value = combine(value, this[i]);
@@ -686,7 +683,6 @@
}
double lastWhere(bool test(double element), {double orElse()}) {
- var result = null;
var len = this.length;
for (var i = len - 1; i >= 0; --i) {
var element = this[i];
@@ -874,7 +870,7 @@
}
void shuffle([Random random]) {
- if (random == null) random = new Random();
+ random ??= new Random();
var i = this.length;
while (i > 1) {
int pos = random.nextInt(i);
@@ -994,7 +990,6 @@
Float32x4 reduce(Float32x4 combine(Float32x4 value, Float32x4 element)) {
var len = this.length;
if (len == 0) throw IterableElementError.noElement();
- var i = 0;
var value = this[0];
for (var i = 1; i < len; ++i) {
value = combine(value, this[i]);
@@ -1043,7 +1038,6 @@
}
Float32x4 lastWhere(bool test(Float32x4 element), {Float32x4 orElse()}) {
- var result = null;
var len = this.length;
for (var i = len - 1; i >= 0; --i) {
var element = this[i];
@@ -1234,7 +1228,7 @@
}
void shuffle([Random random]) {
- if (random == null) random = new Random();
+ random ??= new Random();
var i = this.length;
while (i > 1) {
int pos = random.nextInt(i);
@@ -1353,7 +1347,6 @@
Int32x4 reduce(Int32x4 combine(Int32x4 value, Int32x4 element)) {
var len = this.length;
if (len == 0) throw IterableElementError.noElement();
- var i = 0;
var value = this[0];
for (var i = 1; i < len; ++i) {
value = combine(value, this[i]);
@@ -1402,7 +1395,6 @@
}
Int32x4 lastWhere(bool test(Int32x4 element), {Int32x4 orElse()}) {
- var result = null;
var len = this.length;
for (var i = len - 1; i >= 0; --i) {
var element = this[i];
@@ -1593,7 +1585,7 @@
}
void shuffle([Random random]) {
- if (random == null) random = new Random();
+ random ??= new Random();
var i = this.length;
while (i > 1) {
int pos = random.nextInt(i);
@@ -1713,7 +1705,6 @@
Float64x2 reduce(Float64x2 combine(Float64x2 value, Float64x2 element)) {
var len = this.length;
if (len == 0) throw IterableElementError.noElement();
- var i = 0;
var value = this[0];
for (var i = 1; i < len; ++i) {
value = combine(value, this[i]);
@@ -1762,7 +1753,6 @@
}
Float64x2 lastWhere(bool test(Float64x2 element), {Float64x2 orElse()}) {
- var result = null;
var len = this.length;
for (var i = len - 1; i >= 0; --i) {
var element = this[i];
@@ -1913,118 +1903,88 @@
(other is _ByteBuffer) && identical(_data, other._data);
ByteData asByteData([int offsetInBytes = 0, int length]) {
- if (length == null) {
- length = this.lengthInBytes - offsetInBytes;
- }
+ length ??= this.lengthInBytes - offsetInBytes;
return new _ByteDataView(this._data, offsetInBytes, length);
}
Int8List asInt8List([int offsetInBytes = 0, int length]) {
- if (length == null) {
- length = this.lengthInBytes - offsetInBytes;
- }
+ length ??= this.lengthInBytes - offsetInBytes;
return new _Int8ArrayView(this, offsetInBytes, length);
}
Uint8List asUint8List([int offsetInBytes = 0, int length]) {
- if (length == null) {
- length = this.lengthInBytes - offsetInBytes;
- }
+ length ??= this.lengthInBytes - offsetInBytes;
return new _Uint8ArrayView(this, offsetInBytes, length);
}
Uint8ClampedList asUint8ClampedList([int offsetInBytes = 0, int length]) {
- if (length == null) {
- length = this.lengthInBytes - offsetInBytes;
- }
+ length ??= this.lengthInBytes - offsetInBytes;
return new _Uint8ClampedArrayView(this, offsetInBytes, length);
}
Int16List asInt16List([int offsetInBytes = 0, int length]) {
- if (length == null) {
- length =
- (this.lengthInBytes - offsetInBytes) ~/ Int16List.bytesPerElement;
- }
+ length ??=
+ (this.lengthInBytes - offsetInBytes) ~/ Int16List.bytesPerElement;
return new _Int16ArrayView(this, offsetInBytes, length);
}
Uint16List asUint16List([int offsetInBytes = 0, int length]) {
- if (length == null) {
- length =
- (this.lengthInBytes - offsetInBytes) ~/ Uint16List.bytesPerElement;
- }
+ length ??=
+ (this.lengthInBytes - offsetInBytes) ~/ Uint16List.bytesPerElement;
return new _Uint16ArrayView(this, offsetInBytes, length);
}
Int32List asInt32List([int offsetInBytes = 0, int length]) {
- if (length == null) {
- length =
- (this.lengthInBytes - offsetInBytes) ~/ Int32List.bytesPerElement;
- }
+ length ??=
+ (this.lengthInBytes - offsetInBytes) ~/ Int32List.bytesPerElement;
return new _Int32ArrayView(this, offsetInBytes, length);
}
Uint32List asUint32List([int offsetInBytes = 0, int length]) {
- if (length == null) {
- length =
- (this.lengthInBytes - offsetInBytes) ~/ Uint32List.bytesPerElement;
- }
+ length ??=
+ (this.lengthInBytes - offsetInBytes) ~/ Uint32List.bytesPerElement;
return new _Uint32ArrayView(this, offsetInBytes, length);
}
Int64List asInt64List([int offsetInBytes = 0, int length]) {
- if (length == null) {
- length =
- (this.lengthInBytes - offsetInBytes) ~/ Int64List.bytesPerElement;
- }
+ length ??=
+ (this.lengthInBytes - offsetInBytes) ~/ Int64List.bytesPerElement;
return new _Int64ArrayView(this, offsetInBytes, length);
}
Uint64List asUint64List([int offsetInBytes = 0, int length]) {
- if (length == null) {
- length =
- (this.lengthInBytes - offsetInBytes) ~/ Uint64List.bytesPerElement;
- }
+ length ??=
+ (this.lengthInBytes - offsetInBytes) ~/ Uint64List.bytesPerElement;
return new _Uint64ArrayView(this, offsetInBytes, length);
}
Float32List asFloat32List([int offsetInBytes = 0, int length]) {
- if (length == null) {
- length =
- (this.lengthInBytes - offsetInBytes) ~/ Float32List.bytesPerElement;
- }
+ length ??=
+ (this.lengthInBytes - offsetInBytes) ~/ Float32List.bytesPerElement;
return new _Float32ArrayView(this, offsetInBytes, length);
}
Float64List asFloat64List([int offsetInBytes = 0, int length]) {
- if (length == null) {
- length =
- (this.lengthInBytes - offsetInBytes) ~/ Float64List.bytesPerElement;
- }
+ length ??=
+ (this.lengthInBytes - offsetInBytes) ~/ Float64List.bytesPerElement;
return new _Float64ArrayView(this, offsetInBytes, length);
}
Float32x4List asFloat32x4List([int offsetInBytes = 0, int length]) {
- if (length == null) {
- length =
- (this.lengthInBytes - offsetInBytes) ~/ Float32x4List.bytesPerElement;
- }
+ length ??=
+ (this.lengthInBytes - offsetInBytes) ~/ Float32x4List.bytesPerElement;
return new _Float32x4ArrayView(this, offsetInBytes, length);
}
Int32x4List asInt32x4List([int offsetInBytes = 0, int length]) {
- if (length == null) {
- length =
- (this.lengthInBytes - offsetInBytes) ~/ Int32x4List.bytesPerElement;
- }
+ length ??=
+ (this.lengthInBytes - offsetInBytes) ~/ Int32x4List.bytesPerElement;
return new _Int32x4ArrayView(this, offsetInBytes, length);
}
Float64x2List asFloat64x2List([int offsetInBytes = 0, int length]) {
- if (length == null) {
- length =
- (this.lengthInBytes - offsetInBytes) ~/ Float64x2List.bytesPerElement;
- }
+ length ??=
+ (this.lengthInBytes - offsetInBytes) ~/ Float64x2List.bytesPerElement;
return new _Float64x2ArrayView(this, offsetInBytes, length);
}
}
@@ -3572,7 +3532,7 @@
_TypedListView(_ByteBuffer _buffer, int _offset, int _length)
: _typedData = _buffer._data,
offsetInBytes = _offset,
- length = _length {}
+ length = _length;
// Method(s) implementing the TypedData interface.