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

Unified Diff: tool/input_sdk/patch/core_patch.dart

Issue 1071393007: fuse List and js Array together and a few other misc fixes. (Closed) Base URL: git@github.com:dart-lang/dart-dev-compiler.git@master
Patch Set: ptal Created 5 years, 8 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 | « tool/input_sdk/lib/core/list.dart ('k') | tool/input_sdk/private/js_helper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tool/input_sdk/patch/core_patch.dart
diff --git a/tool/input_sdk/patch/core_patch.dart b/tool/input_sdk/patch/core_patch.dart
index ddd7e0a2ce7e7d8c9b062fb0fe34cce32488f2f5..7676ac4a3f3821bd4465c74d6172b7a67417ed1f 100644
--- a/tool/input_sdk/patch/core_patch.dart
+++ b/tool/input_sdk/patch/core_patch.dart
@@ -242,11 +242,19 @@ class _ListConstructorSentinel {
@patch
class List<E> {
@patch
- factory List([int length = const _ListConstructorSentinel()]) {
- if (length == const _ListConstructorSentinel()) {
- return new JSArray<E>.emptyGrowable();
+ factory List([int length]) {
+ if (length == null) {
+ return JS('', '[]');
}
- return new JSArray<E>.fixed(length);
+ // Explicit type test is necessary to guard against JavaScript conversions
+ // in unchecked mode.
+ if ((length is !int) || (length < 0)) {
+ throw new ArgumentError("Length must be a non-negative integer: $length");
+ }
+ var list = JS('', 'new Array(#)', length);
+ // TODO(jmesserly): consider a fixed array subclass instead.
+ JS('void', r'#.fixed$length = Array', list);
+ return list;
}
@patch
« no previous file with comments | « tool/input_sdk/lib/core/list.dart ('k') | tool/input_sdk/private/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698