diff --git a/sdk/lib/_internal/wasm/lib/compact_hash.dart b/sdk/lib/_internal/wasm/lib/compact_hash.dart index bd78968e58d..931d4781da2 100644 --- a/sdk/lib/_internal/wasm/lib/compact_hash.dart +++ b/sdk/lib/_internal/wasm/lib/compact_hash.dart @@ -4,6 +4,7 @@ import "dart:_internal" show IterableElementError, ClassID, TypeTest, unsafeCast; +import "dart:_list" show GrowableList; import "dart:_wasm"; import "dart:collection"; @@ -443,7 +444,7 @@ mixin _LinkedHashMapMixin on _HashBase, _EqualsAndHashCode { /// This function is unsafe: it does not perform any type checking on /// keys and values assuming that caller has ensured that types are /// correct. - void _populateUnsafe(List keyValuePairs) { + void _populateUnsafe(GrowableList keyValuePairs) { assert(keyValuePairs.length.isEven); int size = _roundUpToPowerOfTwo(keyValuePairs.length); if (size < _HashBase._INITIAL_INDEX_SIZE) { @@ -1130,5 +1131,6 @@ base class CompactLinkedCustomHashSet extends _HashFieldBase } @pragma('wasm:prefer-inline') -Map createMapFromKeyValueListUnsafe(List keyValuePairs) => +Map createMapFromKeyValueListUnsafe( + GrowableList keyValuePairs) => DefaultMap().._populateUnsafe(keyValuePairs); diff --git a/sdk/lib/_internal/wasm/lib/convert_patch.dart b/sdk/lib/_internal/wasm/lib/convert_patch.dart index 30a4079f1ab..ef1a2403b06 100644 --- a/sdk/lib/_internal/wasm/lib/convert_patch.dart +++ b/sdk/lib/_internal/wasm/lib/convert_patch.dart @@ -6,10 +6,11 @@ import "dart:_compact_hash" show createMapFromKeyValueListUnsafe; import "dart:_internal" show patch, POWERS_OF_TEN, unsafeCast; import "dart:_js_string_convert"; import "dart:_js_types"; +import "dart:_list" show GrowableList; import "dart:_string"; import "dart:_typed_data"; import "dart:_wasm"; -import "dart:typed_data" show Uint8List, Uint16List; +import "dart:typed_data" show Uint8List; /// This patch library has no additional parts. @@ -87,7 +88,7 @@ class _JsonListener { * * When building [Map] this will contain array of key-value pairs. */ - List? currentContainer; + GrowableList? currentContainer; /** The most recently read value. */ Object? value; @@ -95,13 +96,13 @@ class _JsonListener { /** Pushes the currently active container. */ void beginContainer() { stack.add(currentContainer); - currentContainer = []; + currentContainer = GrowableList.empty(); } /** Pops the top container from the [stack]. */ void popContainer() { value = currentContainer; - currentContainer = unsafeCast(stack.removeLast()); + currentContainer = unsafeCast(stack.removeLast()); } void handleString(String value) { @@ -125,12 +126,12 @@ class _JsonListener { } void propertyName() { - unsafeCast(currentContainer).add(value); + unsafeCast(currentContainer).add(value); value = null; } void propertyValue() { - final keyValuePairs = unsafeCast(currentContainer); + final keyValuePairs = unsafeCast(currentContainer); if (reviver case final reviver?) { final key = keyValuePairs.last; keyValuePairs.add(reviver(key, value)); @@ -143,7 +144,7 @@ class _JsonListener { void endObject() { popContainer(); value = createMapFromKeyValueListUnsafe( - unsafeCast(value)); + unsafeCast(value)); } void beginArray() {