Skip to content

Commit 8047d62

Browse files
askeksaCommit Bot
authored andcommitted
Revert "[vm,dart2wasm] Move hash factory code to enable sharing of patch files"
This reverts commit 04372ad. Reason for revert: Flutter PR not rolled into g3 yet. Original change's description: > [vm,dart2wasm] Move hash factory code to enable sharing of patch files > > By moving the hash map/set factories into their own file, the > collection_patch and compact_hash patch files can be shared between the > VM and dart2wasm. > > This builds on the preparations from the creation of the file in > https://dart-review.googlesource.com/c/sdk/+/229905 and listing it in > the Flutter file lists in flutter/engine#31133. > > Change-Id: Ia8f07229af056e59b119008714deecc0c96dd742 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231947 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Aske Simon Christensen <askesc@google.com> TBR=askesc@google.com,dacoharkes@google.com Change-Id: I6342ef0250cc24b36c4c32e86a4769dbaeffafa4 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232400 Reviewed-by: Aske Simon Christensen <askesc@google.com> Commit-Queue: Aske Simon Christensen <askesc@google.com>
1 parent 04372ad commit 8047d62

2 files changed

Lines changed: 72 additions & 64 deletions

File tree

sdk/lib/_internal/vm/lib/collection_patch.dart

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,3 +849,72 @@ class _HashSetIterator<E> implements Iterator<E> {
849849

850850
E get current => _current as E;
851851
}
852+
853+
/**
854+
* A hash-based map that iterates keys and values in key insertion order.
855+
* This is never actually instantiated any more - the constructor always
856+
* returns an instance of _CompactLinkedHashMap or _InternalLinkedHashMap,
857+
* which despite the names do not use links (but are insertion-ordered as if
858+
* they did).
859+
*/
860+
@patch
861+
class LinkedHashMap<K, V> {
862+
@patch
863+
factory LinkedHashMap(
864+
{bool equals(K key1, K key2)?,
865+
int hashCode(K key)?,
866+
bool isValidKey(potentialKey)?}) {
867+
if (isValidKey == null) {
868+
if (hashCode == null) {
869+
if (equals == null) {
870+
return new _InternalLinkedHashMap<K, V>();
871+
}
872+
hashCode = _defaultHashCode;
873+
} else {
874+
if (identical(identityHashCode, hashCode) &&
875+
identical(identical, equals)) {
876+
return new _CompactLinkedIdentityHashMap<K, V>();
877+
}
878+
equals ??= _defaultEquals;
879+
}
880+
} else {
881+
hashCode ??= _defaultHashCode;
882+
equals ??= _defaultEquals;
883+
}
884+
return new _CompactLinkedCustomHashMap<K, V>(equals, hashCode, isValidKey);
885+
}
886+
887+
@patch
888+
factory LinkedHashMap.identity() => new _CompactLinkedIdentityHashMap<K, V>();
889+
}
890+
891+
@patch
892+
class LinkedHashSet<E> {
893+
@patch
894+
factory LinkedHashSet(
895+
{bool equals(E e1, E e2)?,
896+
int hashCode(E e)?,
897+
bool isValidKey(potentialKey)?}) {
898+
if (isValidKey == null) {
899+
if (hashCode == null) {
900+
if (equals == null) {
901+
return new _CompactLinkedHashSet<E>();
902+
}
903+
hashCode = _defaultHashCode;
904+
} else {
905+
if (identical(identityHashCode, hashCode) &&
906+
identical(identical, equals)) {
907+
return new _CompactLinkedIdentityHashSet<E>();
908+
}
909+
equals ??= _defaultEquals;
910+
}
911+
} else {
912+
hashCode ??= _defaultHashCode;
913+
equals ??= _defaultEquals;
914+
}
915+
return new _CompactLinkedCustomHashSet<E>(equals, hashCode, isValidKey);
916+
}
917+
918+
@patch
919+
factory LinkedHashSet.identity() => new _CompactLinkedIdentityHashSet<E>();
920+
}

sdk/lib/_internal/vm/lib/hash_factories.dart

Lines changed: 3 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2,67 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// The [LinkedHashMap] and [LinkedHashSet] factory constructors return different
6-
// internal implementations depending on the supplied callback functions.
7-
8-
@patch
9-
class LinkedHashMap<K, V> {
10-
@patch
11-
factory LinkedHashMap(
12-
{bool equals(K key1, K key2)?,
13-
int hashCode(K key)?,
14-
bool isValidKey(potentialKey)?}) {
15-
if (isValidKey == null) {
16-
if (hashCode == null) {
17-
if (equals == null) {
18-
return new _InternalLinkedHashMap<K, V>();
19-
}
20-
hashCode = _defaultHashCode;
21-
} else {
22-
if (identical(identityHashCode, hashCode) &&
23-
identical(identical, equals)) {
24-
return new _CompactLinkedIdentityHashMap<K, V>();
25-
}
26-
equals ??= _defaultEquals;
27-
}
28-
} else {
29-
hashCode ??= _defaultHashCode;
30-
equals ??= _defaultEquals;
31-
}
32-
return new _CompactLinkedCustomHashMap<K, V>(equals, hashCode, isValidKey);
33-
}
34-
35-
@patch
36-
factory LinkedHashMap.identity() => new _CompactLinkedIdentityHashMap<K, V>();
37-
}
38-
39-
@patch
40-
class LinkedHashSet<E> {
41-
@patch
42-
factory LinkedHashSet(
43-
{bool equals(E e1, E e2)?,
44-
int hashCode(E e)?,
45-
bool isValidKey(potentialKey)?}) {
46-
if (isValidKey == null) {
47-
if (hashCode == null) {
48-
if (equals == null) {
49-
return new _CompactLinkedHashSet<E>();
50-
}
51-
hashCode = _defaultHashCode;
52-
} else {
53-
if (identical(identityHashCode, hashCode) &&
54-
identical(identical, equals)) {
55-
return new _CompactLinkedIdentityHashSet<E>();
56-
}
57-
equals ??= _defaultEquals;
58-
}
59-
} else {
60-
hashCode ??= _defaultHashCode;
61-
equals ??= _defaultEquals;
62-
}
63-
return new _CompactLinkedCustomHashSet<E>(equals, hashCode, isValidKey);
64-
}
65-
66-
@patch
67-
factory LinkedHashSet.identity() => new _CompactLinkedIdentityHashSet<E>();
68-
}
5+
// This is a placeholder file which will shortly contain the LinkedhashMap and
6+
// LinkedHashSet patches from collection_patch.dart. The change is done in two
7+
// steps to ease rolling it into Flutter.

0 commit comments

Comments
 (0)