Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Unified Diff: runtime/lib/collection_patch.dart

Issue 2759973004: Fix observatory tests broken by running dartfmt. Temporarily reverted formatting for evaluate_activ… (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/bool_patch.dart ('k') | runtime/lib/compact_hash.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/collection_patch.dart
diff --git a/runtime/lib/collection_patch.dart b/runtime/lib/collection_patch.dart
index f7cd33d1da5a630eb92428c25db8702185bca654..aca1f775ee70a8166e1694e96b41c5491e149396 100644
--- a/runtime/lib/collection_patch.dart
+++ b/runtime/lib/collection_patch.dart
@@ -5,10 +5,13 @@
import 'dart:typed_data';
import 'dart:_internal' as internal;
-@patch class HashMap<K, V> {
- @patch factory HashMap({ bool equals(K key1, K key2),
- int hashCode(K key),
- bool isValidKey(potentialKey) }) {
+@patch
+class HashMap<K, V> {
+ @patch
+ factory HashMap(
+ {bool equals(K key1, K key2),
+ int hashCode(K key),
+ bool isValidKey(potentialKey)}) {
if (isValidKey == null) {
if (hashCode == null) {
if (equals == null) {
@@ -35,18 +38,17 @@ import 'dart:_internal' as internal;
return new _CustomHashMap<K, V>(equals, hashCode, isValidKey);
}
- @patch factory HashMap.identity() = _IdentityHashMap<K, V>;
+ @patch
+ factory HashMap.identity() = _IdentityHashMap<K, V>;
Set<K> _newKeySet();
}
-
const int _MODIFICATION_COUNT_MASK = 0x3fffffff;
class _HashMap<K, V> implements HashMap<K, V> {
static const int _INITIAL_CAPACITY = 8;
-
int _elementCount = 0;
List<_HashMapEntry> _buckets = new List(_INITIAL_CAPACITY);
int _modificationCount = 0;
@@ -83,7 +85,7 @@ class _HashMap<K, V> implements HashMap<K, V> {
return false;
}
- V operator[](Object key) {
+ V operator [](Object key) {
int hashCode = key.hashCode;
List buckets = _buckets;
int index = hashCode & (buckets.length - 1);
@@ -186,9 +188,8 @@ class _HashMap<K, V> implements HashMap<K, V> {
}
}
- void _removeEntry(_HashMapEntry entry,
- _HashMapEntry previousInBucket,
- int bucketIndex) {
+ void _removeEntry(
+ _HashMapEntry entry, _HashMapEntry previousInBucket, int bucketIndex) {
if (previousInBucket == null) {
_buckets[bucketIndex] = entry.next;
} else {
@@ -196,8 +197,8 @@ class _HashMap<K, V> implements HashMap<K, V> {
}
}
- void _addEntry(List buckets, int index, int length,
- K key, V value, int hashCode) {
+ void _addEntry(
+ List buckets, int index, int length, K key, V value, int hashCode) {
_HashMapEntry entry =
new _HashMapEntry(key, value, hashCode, buckets[index]);
buckets[index] = entry;
@@ -240,7 +241,6 @@ class _CustomHashMap<K, V> extends _HashMap<K, V> {
_CustomHashMap(this._equals, this._hashCode, validKey)
: _validKey = (validKey != null) ? validKey : new _TypeTest<K>().test;
-
bool containsKey(Object key) {
if (!_validKey(key)) return false;
int hashCode = _hashCode(key);
@@ -254,7 +254,7 @@ class _CustomHashMap<K, V> extends _HashMap<K, V> {
return false;
}
- V operator[](Object key) {
+ V operator [](Object key) {
if (!_validKey(key)) return null;
int hashCode = _hashCode(key);
List buckets = _buckets;
@@ -335,7 +335,6 @@ class _CustomHashMap<K, V> extends _HashMap<K, V> {
}
class _IdentityHashMap<K, V> extends _HashMap<K, V> {
-
bool containsKey(Object key) {
int hashCode = identityHashCode(key);
List buckets = _buckets;
@@ -348,7 +347,7 @@ class _IdentityHashMap<K, V> extends _HashMap<K, V> {
return false;
}
- V operator[](Object key) {
+ V operator [](Object key) {
int hashCode = identityHashCode(key);
List buckets = _buckets;
int index = hashCode & (buckets.length - 1);
@@ -426,7 +425,6 @@ class _IdentityHashMap<K, V> extends _HashMap<K, V> {
Set<K> _newKeySet() => new _IdentityHashSet<K>();
}
-
class _HashMapEntry {
final key;
var value;
@@ -452,6 +450,7 @@ class _HashMapKeyIterable<K> extends _HashMapIterable<K> {
action(key);
});
}
+
Set<K> toSet() => _map._newKeySet()..addAll(this);
}
@@ -474,7 +473,8 @@ abstract class _HashMapIterator<E> implements Iterator<E> {
_HashMapEntry _entry;
_HashMapIterator(HashMap map)
- : _map = map, _stamp = map._modificationCount;
+ : _map = map,
+ _stamp = map._modificationCount;
bool moveNext() {
if (_stamp != _map._modificationCount) {
@@ -520,10 +520,13 @@ class _HashMapValueIterator<V> extends _HashMapIterator<V> {
}
}
-@patch class HashSet<E> {
- @patch factory HashSet({ bool equals(E e1, E e2),
- int hashCode(E e),
- bool isValidKey(potentialKey) }) {
+@patch
+class HashSet<E> {
+ @patch
+ factory HashSet(
+ {bool equals(E e1, E e2),
+ int hashCode(E e),
+ bool isValidKey(potentialKey)}) {
if (isValidKey == null) {
if (hashCode == null) {
if (equals == null) {
@@ -550,7 +553,8 @@ class _HashMapValueIterator<V> extends _HashMapIterator<V> {
return new _CustomHashSet<E>(equals, hashCode, isValidKey);
}
- @patch factory HashSet.identity() = _IdentityHashSet<E>;
+ @patch
+ factory HashSet.identity() = _IdentityHashSet<E>;
}
class _HashSet<E> extends _HashSetBase<E> implements HashSet<E> {
@@ -649,7 +653,7 @@ class _HashSet<E> extends _HashSetBase<E> implements HashSet<E> {
void _filterWhere(bool test(E element), bool removeMatching) {
int length = _buckets.length;
- for (int index = 0; index < length; index++) {
+ for (int index = 0; index < length; index++) {
_HashSetEntry entry = _buckets[index];
_HashSetEntry previous = null;
while (entry != null) {
@@ -795,7 +799,8 @@ class _HashSetIterator<E> implements Iterator<E> {
E _current;
_HashSetIterator(_HashSet hashSet)
- : _set = hashSet, _modificationCount = hashSet._modificationCount;
+ : _set = hashSet,
+ _modificationCount = hashSet._modificationCount;
bool moveNext() {
if (_modificationCount != _set._modificationCount) {
@@ -830,7 +835,7 @@ class _LinkedHashMapEntry extends _HashMapEntry {
var _nextEntry;
var _previousEntry;
_LinkedHashMapEntry(key, value, int hashCode, _LinkedHashMapEntry next,
- this._previousEntry, this._nextEntry)
+ this._previousEntry, this._nextEntry)
: super(key, value, hashCode, next) {
_previousEntry._nextEntry = this;
_nextEntry._previousEntry = this;
@@ -897,11 +902,11 @@ class _LinkedHashMapValueIterator<V> extends _LinkedHashMapIterator<V> {
V _getValue(_LinkedHashMapEntry entry) => entry.value;
}
-
/**
* A hash-based map that iterates keys and values in key insertion order.
*/
-@patch class LinkedHashMap<K, V> {
+@patch
+class LinkedHashMap<K, V> {
/// Holds a double-linked list of entries in insertion order.
/// The fields have the same name as the ones in [_LinkedHashMapEntry],
/// and this map is itself used as the head entry of the list.
@@ -910,9 +915,11 @@ class _LinkedHashMapValueIterator<V> extends _LinkedHashMapIterator<V> {
var _nextEntry;
var _previousEntry;
- @patch factory LinkedHashMap({ bool equals(K key1, K key2),
- int hashCode(K key),
- bool isValidKey(potentialKey) }) {
+ @patch
+ factory LinkedHashMap(
+ {bool equals(K key1, K key2),
+ int hashCode(K key),
+ bool isValidKey(potentialKey)}) {
if (isValidKey == null) {
if (hashCode == null) {
if (equals == null) {
@@ -939,14 +946,17 @@ class _LinkedHashMapValueIterator<V> extends _LinkedHashMapIterator<V> {
return new _CompactLinkedCustomHashMap<K, V>(equals, hashCode, isValidKey);
}
- @patch factory LinkedHashMap.identity() =
- _CompactLinkedIdentityHashMap<K, V>;
+ @patch
+ factory LinkedHashMap.identity() = _CompactLinkedIdentityHashMap<K, V>;
}
-@patch class LinkedHashSet<E> {
- @patch factory LinkedHashSet({ bool equals(E e1, E e2),
- int hashCode(E e),
- bool isValidKey(potentialKey) }) {
+@patch
+class LinkedHashSet<E> {
+ @patch
+ factory LinkedHashSet(
+ {bool equals(E e1, E e2),
+ int hashCode(E e),
+ bool isValidKey(potentialKey)}) {
if (isValidKey == null) {
if (hashCode == null) {
if (equals == null) {
@@ -973,6 +983,6 @@ class _LinkedHashMapValueIterator<V> extends _LinkedHashMapIterator<V> {
return new _CompactLinkedCustomHashSet<E>(equals, hashCode, isValidKey);
}
- @patch factory LinkedHashSet.identity() =
- _CompactLinkedIdentityHashSet<E>;
+ @patch
+ factory LinkedHashSet.identity() = _CompactLinkedIdentityHashSet<E>;
}
« no previous file with comments | « runtime/lib/bool_patch.dart ('k') | runtime/lib/compact_hash.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698