| Index: runtime/lib/array_patch.dart
|
| diff --git a/runtime/lib/array_patch.dart b/runtime/lib/array_patch.dart
|
| index 08ef4822a6035f4a663219a9146403d3eca03e61..f931d596f697317cf6329deed2778ccbb2e2744b 100644
|
| --- a/runtime/lib/array_patch.dart
|
| +++ b/runtime/lib/array_patch.dart
|
| @@ -6,12 +6,45 @@
|
| // returns a _GrowableObjectArray if length is null, otherwise returns
|
| // fixed size array.
|
| patch class _ListImpl<E> {
|
| - /* patch */ factory List([int length = null]) {
|
| - if (length === null) {
|
| - return new _GrowableObjectArray<E>();
|
| - } else {
|
| - return new _ObjectArray<E>(length);
|
| + /* patch */ factory List([int length = 0]) {
|
| + if (length is! int || length < 0) {
|
| + throw new ArgumentError("Length must be a positive integer: $length.");
|
| }
|
| + _GrowableObjectArray<E> result = new _GrowableObjectArray<E>();
|
| + if (length != 0) {
|
| + result.length = length;
|
| + }
|
| + return result;
|
| + }
|
| +
|
| + /* patch */ factory List.fixedLength(int length, {E fill: null}) {
|
| + if (length is! int || length < 0) {
|
| + throw new ArgumentError("Length must be a positive integer: $length.");
|
| + }
|
| + _ObjectArray<E> result = new _ObjectArray<E>(length);
|
| + if (fill != null) {
|
| + for (int i = 0; i < length; i++) {
|
| + result[i] = fill;
|
| + }
|
| + }
|
| + return result;
|
| + }
|
| +
|
| + /* patch */ factory List.filled(int length, E fill) {
|
| + if (length is! int || length < 0) {
|
| + throw new ArgumentError("Length must be a positive integer: $length.");
|
| + }
|
| + _GrowableObjectArray<E> result =
|
| + new _GrowableObjectArray<E>.withCapacity(length < 4 ? 4 : length);
|
| + if (length != 0) {
|
| + result.length = length;
|
| + if (fill != null) {
|
| + for (int i = 0; i < length; i++) {
|
| + result[i] = fill;
|
| + }
|
| + }
|
| + }
|
| + return result;
|
| }
|
|
|
| /* patch */ factory List.from(Iterable<E> other) {
|
|
|